TCP/UDP Socket Protocol, Programming
This post was migrated from Tistory. You can find the original here.
TCP/UDP Socket Protocol
The Socket Interface lets you use the TCP and UDP communication protocols.
The Socket Interface is provided in a form tied to a specific OS and programming language.
TCP Socket Programming
The server creates a socket and assigns it an address (Bind). It then waits for connection requests (Listen) and accepts them (Accept). The connection is kept alive while communication happens, and is closed once the logic dictates.
UDP Socket Programming
Unlike TCP, there’s no Listen() or Accept().
Since UDP doesn’t call sendto() over an established connection, each sendto() call corresponds to a single recvfrom() call.
For example, if three sendto() calls pile up before the server’s recvfrom() runs, TCP would handle all that data in a single recvfrom() call, but UDP would require three separate recvfrom() calls.
The packet a UDP socket sends is called a datagram. Unlike a TCP packet, it’s called a datagram because it carries meaning as a single, self-contained piece of data rather than as part of a larger stream.
References
https://andjjip.tistory.com/281
[[Socket Programming] 4. TCP-based Server/Client 1
TCP-based Server/Client 1 Understanding TCP and UDP For sockets based on the internet protocol, they’re divided into TCP sockets and UDP sockets depending on the data transmission method, and since TCP sockets are connection-oriented in particular…
andjjip.tistory.com](https://andjjip.tistory.com/281)
https://andjjip.tistory.com/283
[[Socket Programming] 6. UDP-based Server/Client
UDP-based Server/Client Characteristics of UDP sockets I’ll explain how UDP works using the analogy of a letter. To send a letter, you have to write the sender’s and recipient’s address information on the envelope. And then…
andjjip.tistory.com](https://andjjip.tistory.com/283)


