Inter-process Communication based on UDP Protocol
The main features of UDP protocol are:
UDP is connectionless
UDP uses best efforts to deliver
UDP is message-oriented.
No congestion control
Support one-to-one, one-to-many, many-to-one, many-to-many interactive communication
The first part of UDP has little overhead.
The UDP protocol is connectionless and block oriented. Therefore, the client side does not need to connect with the server side, but sends messages directly.
Server: 1 # include 2 # include 3 # include 4 # include 5 # include 6 # include 7 # include 8 void usage (char * port) 9 {10 printf ("% s, [ip], [port]\ n", port); 11} 12 int main (int argc,char * argv []) 13 {14 if (argv [0]) 15 {16 usage (argv [0]); 17 exit (1) 18} 19 int sock = socket (AF_INET,SOCK_DGRAM,0); / / create socket 20 if (sock