Beruflich Dokumente
Kultur Dokumente
Assignment #6
2. Explain the difference between socket function for TCP and UDP and
write the procedure how the connection is possible in TCP/UDP
In UDP, the client does not establish a connection with the server. Instead,
the client just sends a datagram to the server using the sendto function
which requires the address of the destination as a parameter.
Similarly, the server does not accept a connection from a client. Instead,
the server just calls the recvfrom function, which waits until data arrives
from some client. recvfrom returns the protocol address of the client,
along with the datagram, so the server can send a response to the correct
client.
In TCP the client established a connection with the server and sends
packet to the destination of the server.
Just placing a timeout on the recvform is not the entire solution. For
example, if we do time out, we cannot tell whether our datagram never
made it to the server, or if the server's reply never made it back. If the
client's request was something like "transfer a certain amount of money
from account A to account B", it would make a big difference as to
whether the request was lost or the reply was lost.
141276 Page 1
Apoorv Jain G8 141276
This function is a simple loop that reads the next datagram arriving at the
server's port using recvfrom and sends it back using sendto.
141276 Page 2