UDP is a connection less protocol. There is no connection is established between client and server. Creating Standard UDP Client/Server is discussed here
In UDP, the client does not form a connection with the server like in TCP and instead, It just sends a datagram. Similarly, the server need not to accept a connection and just waits for datagrams to arrive. We can call a function called connect() in UDP but it does not result anything like it does in TCP. There is no 3 way handshake. It just checks for any immediate errors and store the peer’s IP address and port number. connect() is storing peers address so no need to pass server address and server address length arguments in sendto().
Necessary Functions :
int connect(int sockfd, const struct sockaddr *servaddr, socklen_t addrlen); returns : 0 if OK -1 on error arguments : sockfd : File descriptor of socket to be connected. struct sockaddr *servaddr : server address structure. addrlen : length of server address structure.
Below is the implementation showing message transfer between server-client :
UDP Server code :
UDP Client code :
- UDP Server-Client implementation in C
- TCP Server-Client implementation in C
- Java Implementation of Deffi-Hellman Algorithm between Client and Server
- TCP Client-Server Program to Check if a Given String is Palindrome
- HTTP/2 Client feature of Java 9 with Example
- Difference between MS SQL Server and IBM DB2
- Address Resolution in DNS (Domain Name Server)
- How to Launch a WordPress Website using Amazon EC2 Server ?
- Setup Web Server Over Docker Container in Linux
- What to do when load on a Linux based web server goes high?
- Embedding Tomcat Server in Maven Project
- Implementation of ls | wc command
- Implementation of a Falling Matrix
- Implementation of Locking in DBMS
- Array implementation of queue (Simple)
- Generic Implementation of QuickSort Algorithm in C
- Decision tree implementation using Python
- Binary Tree (Array implementation)
- Hamming Code implementation in Python
- Box Blur Algorithm - With Python implementation
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.