Is SMTP based on TCP or UDP?

In theory SMTP can be handled by either TCP, UDP, or some 3rd party protocol. As defined in RFC 821, RFC 2821, and RFC 5321: SMTP is independent of the particular transmission subsystem and requires only a reliable ordered data stream channel. In addition, the Internet Assigned Numbers Authority has allocated port 25 for both … Read more

What’s the purpose of using sendto()/recvfrom() instead of connect()/send()/recv() with UDP sockets?

accept() is for TCP. It has nothing to do with UDP. connect() in UDP doesn’t do anything to the other end, it just conditions the local API to know who you are sending to and receiving from. If you don’t already know that, or don’t care, or want to send to multiple destinations with the … Read more

UDP Socket Set Timeout

The SO_RCVTIMEO option expects a struct timeval defined in sys/time.h, not an integer like you’re passing to it. The timeval struct has as field for seconds and a field for microseconds. To set the timeout to 100ms, the following should do the trick: struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 100000; if (setsockopt(rcv_sock, SOL_SOCKET, … Read more

TCP stream vs UDP message

The interface/API presented to you the user(programmer) of these protocols are: UDP Message oriented, you have an API (send/recv and similar) that provide you with the ability to send one datagram, and receive one datagram. 1 send() call results in 1 datagram sent, and 1 recv() call will recieve exactly 1 datagram. TCP Stream oriented, … Read more

UDP vs IP- difference?

Then what is the point of UDP when we already have IP? To multiplex services. The UDP port number can differentiate between multiple services on the same host, using the same L3 identification. Using IP only it wouldn’t be possible to host multiple services on the same station and easily differentiate between them. Also, consider … Read more