learn network programming in c, but without all those pesky sockets

learn network programming in c, but without all those pesky sockets

Low Level Learning

1 год назад

89,936 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Low Level Learning
Low Level Learning - 29.10.2022 18:20

Leave a comment, let me know what YOUR favorite networking library is!

Ответить
Qeqsique Mechanical
Qeqsique Mechanical - 31.08.2023 20:12

that's cool, but what about performance tradeoff?

Ответить
John Doe
John Doe - 27.08.2023 08:01

LocalHorse Gang checking in here

Ответить
AbdulMuneem Rustem
AbdulMuneem Rustem - 13.06.2023 08:58

Bro i just love the things you do like socket code was a headache for many months but thanks to you now Im relieved

Ответить
klamberext
klamberext - 06.05.2023 13:35

Localhorse..

Ответить
lynxthecat
lynxthecat - 28.04.2023 17:36

Zeromq rocks

Ответить
P H
P H - 27.04.2023 14:35

I love this video. Thank you so much. Now i want MORE SOCKET RELATED PROJECTS

Ответить
Redmund Perrz
Redmund Perrz - 12.03.2023 19:51

This got my attention 😮😮

Ответить
Dijkstra
Dijkstra - 19.02.2023 21:49

at first looking at the title I thought this man was gonna interface the network card directly

Ответить
Bill Clinton
Bill Clinton - 03.02.2023 09:03

Bro is asking to get hacked.

Ответить
thehunter
thehunter - 25.01.2023 21:24

very rarely people talk about zeromq

Ответить
John Durham
John Durham - 15.01.2023 08:57

This is sweet. Sockets is fine but I'm already bangin away at some crazy stuff with this API. Thanks L3!

Ответить
edgeeffect
edgeeffect - 13.01.2023 02:29

In my day job (sadly) I do a lot of web development... this seems very familiar. Nice.

Ответить
this is really me
this is really me - 10.01.2023 06:59

Thanks. Maybe someday it’d be great to do the same thing in sockets, revisit 0mq at the same time… sort of a compare and contrast.

Ответить
Alexandro Hdez
Alexandro Hdez - 08.01.2023 09:25

It would be nice a Demo using libcurl library and then integrates with a json parser library 😉. Great video 🙏

Ответить
Dissonance
Dissonance - 19.12.2022 18:11

Dude doesn't know what Ø is

Ответить
Vaiovha
Vaiovha - 09.12.2022 07:24

I've heard of ZeroMQ but not CZMQ. Is it like a more simplified version?

As for my favorite net lib? In C, I'm using the sockets API directly, with Winsock startup/shutdown boilerplate, because I need like raw TCP/UDP a lot of the time. I want to use Rust, but that's where networking gets... complicated, especially with concurrency, which I'm also struggling with, though the channel semantics look promising. The `tokio` crate seems like the go-to, but if you need a program to do expensive calculations as well (ie. a server-side authority game server), that's where it falls short. I was told to use std::net in conjunction with the `rayon` crate in such cases, but concurrency and networking on that scale makes brain soup.

Ответить
fire ball
fire ball - 08.12.2022 01:54

Nice video but It reminds me why I don't like programming in C for networking. Header files, **, * &, free etc

Ответить
Lucian Maricuta
Lucian Maricuta - 07.12.2022 11:31

What I like about sockets are the IO Strategy, especially multiplexing, to handle multiple sockets, using select option to select only the sockets that has pending data, and IOCTL where you can check the state of a socket or set a block state to a socket.

For socket strategy there is IOStrategy, Async and Multi-threaded,
- IO strategy uses a single thread where it selects sockets that have pending data to handle them,
- Async uses opens and closes or uses a thread-pool to handle sockets in separate threads, if you have to synchronize data received from the sockets you have to synchronize it manually
- Multi-threaded handles sockets in separate threads, in my opinion multi-threaded should be avoided, it is the easiest to handle but the slowest when handling a lot of clients,
- There is also an hybrid mode where using IO Strategy in separate threads as socket channels, for example

I also wrote 3 layers of abstraction for the socket library in c++, Socket->DataSocket ->Listening and Connection socket, after this I wrote the communication protocol, because send and recv, does not ensure, you will receive the full message, because if the message is too big, it will be broken into chunks or receive part of the next message, especially if you have blocking turned off per socket

A good socket library should have options to use their own strategy(IOStrategy, Async, Multi-threaded, etc,) to handle sockets, an easy to use listening and connection socket, also a communication protocol,

Ответить
Kevin Stefanov
Kevin Stefanov - 04.12.2022 19:00

Do you have / are you going to make a video on the Linux Sockets API?

Ответить
Michael Lenczewski
Michael Lenczewski - 02.12.2022 09:08

ØMQ is a facade then? It kinda sounds like a Plan9 channel.

Ответить
mochou
mochou - 24.11.2022 00:37

localhorse

Ответить
0xgerbot_
0xgerbot_ - 22.11.2022 18:57

Awesome video, that PTSD from the socket API got me looking for alternatives. Thank you very much!

Ответить
ic3man5
ic3man5 - 14.11.2022 18:37

You aren't checking that zsock_new isn't returning NULL.

Ответить
John Smith
John Smith - 12.11.2022 19:25

> networking in c but without all those pesky sockets
> so we're going to be using zsock

Ответить
fluent sloffy
fluent sloffy - 11.11.2022 03:42

you need to shift your video back a little the slight audio desync is fucking killing me

Ответить
dn ce
dn ce - 10.11.2022 17:40

gente una pregunta paa mi tarea xd, he notado que las ip en el router termina en .0.123 por ejemplo y en mi compu la ip termina en .0.14, mi duda, ¿entonces las ip de las computadoras son heredadas de la ip del router o me equivoco? es para una tarea

Ответить
Programming & Design
Programming & Design - 07.11.2022 14:13

Spent all day trying to compile ZeroMQ in Visual Studio 2019 with its C++ binding. Learned I've to move on and find something else. Maybe I can compile its C binding on Linux and use the generated library back on Visual Studio (Windows)? Don't want to lose more hours. Also, couldn't find an understandable example of how to implement async named pipes on Windows with C++.

Ответить
Mikael Lövqvist
Mikael Lövqvist - 07.11.2022 10:47

Interesting how zmq have stuff running post main to detect non freed resources. Maybe that's a signal handler or something, will grep for dangling in the source when I have an opportunity. Thanks for the video!

Ответить
Jason Fernandez
Jason Fernandez - 06.11.2022 19:14

Why didn't localhost work on the server side?

Ответить
Andrew Payne
Andrew Payne - 05.11.2022 15:13

Didn’t you need to allocate a number of bytes for the returned msg string? You just have char *msg in the server and char *str in the client without allocation. Maybe I’m looking too far into this quick demo but just curious as welll.

Ответить
Geoff McQueen
Geoff McQueen - 03.11.2022 07:08

Remove `sleep(1);`

Ответить
Chisco Garcia Gonzalez
Chisco Garcia Gonzalez - 03.11.2022 00:09

Have you heard about DDS?

Ответить
WazzaM
WazzaM - 02.11.2022 21:46

This is messaging middle-ware and not network programming. They are different users completely. And not just an abstraction.
Also the TCP/IP network programming API is from UNIX not Linux.

Ответить
John Robertson
John Robertson - 02.11.2022 16:00

Before investing your time in 0MQ, here are a few considerations:
* The sockets API is well documented, and underlies all IP based networking software. You'll need to learn it sooner or later.
* 0MQ is not a replacement for the sockets API; rather, 0MQ is a pub/sub networking toolkit built on top of the sockets API.
* NATS is a similar pub/sub toolkit which is widely used in industry, but with better intrinsic security than OMQ.
* If you want to write networking software which is as reliable as possible, you will need to learn how to use non-blocking I/O with a single thread. 0MQ (and NATS) kick this can down the road by using seperate threads under the hood to buffer messages.

Ответить
Arion vulgaris
Arion vulgaris - 02.11.2022 13:51

I tried to use zmq once in the project, but realized that it does not guarantee delivery on its own. I read parts of zmq source and it appears to me that data, which was sent from zmq and is then in OS network buffer, may get lost when TCP connection will break. Zmq will do re-connection for you, but data from OS buffer may never get to the destination. So without implementing some acknowledge protocol over zmq messages I could not be sure that data put to zmq will be actually delivered. I tried to do that and it was like re-implementing TCP in simplified form. Another solution I came up was to listen to socket events (or whatever it was called) and reacting on disconnections in some way.

Ответить
FalcoGer
FalcoGer - 02.11.2022 11:16

and that's why I don't like c. global namespace everything.

Ответить
ChonchJohnch
ChonchJohnch - 02.11.2022 06:54

I remember the semester where the pandemic started, my system programming course had us do an IRC client. It was a mess. I'd comfortably say I was the most advanced in the class and I barely managed to finish it.

Ответить
Andre Müller
Andre Müller - 01.11.2022 23:24

I used ~5 years ago zmq for a RADAR-System to transmit processed I/Q-Data to a websocket-server. From there on, the clients received the data via websockets inside the provided web application.

Ответить
Rodolfo Blasser
Rodolfo Blasser - 01.11.2022 17:56

Awesome! Looks promising for embedded devs.

Ответить
Malcolm Swart
Malcolm Swart - 31.10.2022 08:50

I have been using ZMQ for awhile now to build distributed computing software for Manufacturing and Execution Systems and it works really great... can do anything from normal pub sub and req resp patterns to esoteric patterns like radio dish and multi stage compute pipelines. Maybe someday someone can show it working on an ESP32 or similar...

Ответить
CallousCoder
CallousCoder - 31.10.2022 03:27

You forgot an exit after your bind check. Now it will still go into the loop.
Ugh the receive call returns a pointer to data?! That is a daft implementation. You would want to pass a point to a data block, Because now you need to free the pointer to the data after everything call.
Otherwise when you pass in a data pointer you would just free it after your client is done. This returning of a data pointer is not very C-like.

Ответить
Achronath
Achronath - 30.10.2022 18:54

I sure love binding to tcp://localhorse:5555

Ответить
Orko
Orko - 30.10.2022 12:21

Hi, wouldn't the zsock_destroy function in server.c never be called ? Wouldn't it be better to setup a function whenever a SIGINT is received that destroys the socket and terminate the server ?

Ответить
Manifestor
Manifestor - 30.10.2022 12:05

cool but what if we need to serve 1000 clients asynchronously? maybe io_uring (liburing) will help?

Ответить
Ivelin Karageorgiev
Ivelin Karageorgiev - 30.10.2022 10:48

Thanks man, awesome vid.
I've just started to use this library to deploy C code directly to a Raspberry Pi robot of mine.
it's super useful. Keep Rocking \m/

Ответить
bdbdbd
bdbdbd - 30.10.2022 01:07

Does this shit work on Zig too?

Ответить
Abdulfatah Alturshani
Abdulfatah Alturshani - 30.10.2022 00:29

Nahh, I’ll just stick to sockets, plus it’s not doing a lot of abstraction, still bind and connect, what if u wanna use UDP instead of TCP !! though I really loved the way how it giving a warning about the not freed socket.

Ответить
Sezar Starscourge
Sezar Starscourge - 29.10.2022 23:34

cool

Ответить