How to Send and Receive UDP packets (in C)

  Рет қаралды 8,340

Jacob Sorber

Jacob Sorber

Күн бұрын

Пікірлер
@Mronmovies
@Mronmovies 4 ай бұрын
Nice vid! A raw sockets video would be super! Also, it would be awesome to do a deep dive into the network stack, perhaps sk_buff?
@rico_1617
@rico_1617 4 ай бұрын
Legend, literally posted this the day my networking course starts and there's an assignment with UDP lol
@migus925
@migus925 2 ай бұрын
nice video bro, your channel is gold!!
@BLSrr
@BLSrr 4 ай бұрын
Testing can also be done with socat or nc, both sending and receiving.
@Barakatic
@Barakatic 4 ай бұрын
Very nice repeating so keep formula solid in your mind with time .
@newoap
@newoap Ай бұрын
What version of C are you using? That not equal sign on line 10 at 3:51 is unusual.
@esrx7a
@esrx7a 4 ай бұрын
Super, is TCP coming up?
@JacobSorber
@JacobSorber 4 ай бұрын
I have a few stream socket examples that use TCP. Or are you hoping for a deep dive into the details of TCP?
@esrx7a
@esrx7a 4 ай бұрын
@@JacobSorber TCP demystified
@Albert-yd1wh
@Albert-yd1wh 4 ай бұрын
I think it is useful to include continuous receiving packets in the tutorial. Because it is used more often than receiving a single packet.
@mehregankbi
@mehregankbi 4 ай бұрын
Would love a video about unix and raw sockets.
@ahmadshami5847
@ahmadshami5847 4 ай бұрын
Cool video, but I've been always curious about the different ways to handle data coming through the network when it is larger than the defined the buffer. I do have an idea about maybe using fgets whith stdin for example to handle undefined data size but idk if it's the same case with data coming through a network socket.
@LarryEvilsizer
@LarryEvilsizer 4 ай бұрын
Thanks for your videos. My current main project is a network simulator so I'm generally interested in socket examples. I'm wondering what happened to the datagram sent around 11:10? It wasn't received by the receiver program.
@CosmicCoder
@CosmicCoder 4 ай бұрын
I was wondering the same thing. Perhaps they were on different instances of virtual machines?
@Gr4cer
@Gr4cer 4 ай бұрын
That's the beauty of UDP, it's "fire-and-forget". So you can just blast UDP pakets into the void, if theres no one listening, the message is just discarded by any connected node. Even though, as a sender you'll never know if someone or anyone has received the UDP paket. While TCP is doing a lot of handshakes such like regular heartbeats to check if the peer is still alive and connected, an acknowledge for each sent packet, packet resend features etc. which cause some overhead but UDP does none of those things on UDP-Protocol level. Many Applications that use UDP do have some counter included in their procotol so the receiving application can notice if there was a packet dropped.
@CosmicCoder
@CosmicCoder 4 ай бұрын
​@Gr4cer Ah! If there is no "active" listener bound to the port, the datagram is just discarded.
@LarryEvilsizer
@LarryEvilsizer 4 ай бұрын
@@CosmicCoder Thank you very much for your response
@LarryEvilsizer
@LarryEvilsizer 4 ай бұрын
@@Gr4cer Thanks for your response and excellent explanation.
@johangericke1492
@johangericke1492 8 күн бұрын
Okay, so since connect isn't really a thing with UDP, how do you handle multiple connections without using threads/forks? Or are those the only way?
@JacobSorber
@JacobSorber 6 күн бұрын
Well, if you are using UDP, then there are no connections, at least not provided by the underlying protocol. You could set up your own connection abstraction between two end-points that you manage in your code. And, in that case, yes you could handle multiple concurrent connections like you do with TCP, using threads or processes.
@MathematicsStudent
@MathematicsStudent 4 ай бұрын
I seem to remember reading somewhere that connect can still be called for datagram sockets and that it has the effect of setting the default address for sending on that socket. Is that true?
@JacobSorber
@JacobSorber 4 ай бұрын
It is, indeed. I personally don't love using connect with UDP sockets, because it seems (at least to me) to imply a connection (like you have with TCP) where there isn't one. Could confuse some people reading the code, but yes, it does work that way.
@gunar3939
@gunar3939 4 ай бұрын
Need socket timeout also other method to remove blocking functionality
@adsfaedaer
@adsfaedaer 4 ай бұрын
++(wire shark)
@AaronMatlock
@AaronMatlock 4 ай бұрын
The check in this example needs to close the socket.
@ДаниилРябов-з7ь
@ДаниилРябов-з7ь 4 ай бұрын
when http on stm32
Can I use connect with UDP sockets?
4:16
Jacob Sorber
Рет қаралды 3,3 М.
How to make memory read-only in your C programs.
12:57
Jacob Sorber
Рет қаралды 21 М.
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
How do I access a single bit?
11:07
Jacob Sorber
Рет қаралды 23 М.
Student programmers, ChatGPT is not your friend
13:46
Jacob Sorber
Рет қаралды 13 М.
You Don't Know Network Programming
2:20:44
Tsoding Daily
Рет қаралды 73 М.
Makefiles, but in English
55:45
801Labs
Рет қаралды 32 М.
Stop using std::vector wrong
23:14
The Cherno
Рет қаралды 170 М.
Using read write locks (example in C)
17:11
Jacob Sorber
Рет қаралды 7 М.
How one thread listens to many sockets with select in C.
12:01
Jacob Sorber
Рет қаралды 102 М.
Coding a Web Server in 25 Lines - Computerphile
17:49
Computerphile
Рет қаралды 361 М.
Arenas, strings and Scuffed Templates in C
12:28
VoxelRifts
Рет қаралды 104 М.
How does fork work with open files?
13:12
Jacob Sorber
Рет қаралды 10 М.
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН