The general steps for TCP programming servers are as follows:
1. Create a socket and use the function socket (); 2. Set the socket property. Use the setsockopt () function. * optional. 3. Bind the IP address, port, and other information to the socket, and use the function BIND (); 4. Enable the listener and use the listen () function (); 5. Use the accept () function to receive connections from the client (); 6. send and receive data using the send () and Recv () functions, or read () and write () functions (); 7. disable network connections; 8. Disable the listener; |
The common steps for TCP programming clients are as follows:
1. Create a socket and use the function socket (); 2. Set the socket property. Use the setsockopt () function. * optional. 3. Bind the IP address, port, and other information to the socket. Use the BIND function (). * optional 4. Set the IP address and port of the Peer to be connected; 5. Connect to the server and use the function connect (); 6. send and receive data using the send () and Recv () functions, or read () and write () functions (); 7. disable network connections; |
The general steps for UDP programming on the server side are:
1. Create a socket and use the function socket (); 2. Set the socket property. Use the setsockopt () function. * optional. 3. Bind the IP address, port, and other information to the socket, and use the function BIND (); 4. receive data cyclically. Use the recvfrom () function (); 5. disable network connections; |
The general steps for UDP programming clients are as follows:
1. Create a socket and use the function socket (); 2. Set the socket property. Use the setsockopt () function. * optional. 3. Bind the IP address, port, and other information to the socket. Use the BIND function (). * optional 4. Set attributes such as the IP address and port of the peer; 5. Send data using the sendto () function (); 6. Disable the network connection; |