Network concurrency a Socket (TCP) a simple server Seriver

Insert picture description here
1. Client
Client The client can be simply regarded as a process of reading and writing files
1. Establish a socket socket (equivalent to opening a file pointer File*)
2. Connect to the server (open the file fopen)
3. To the service Send data at the end (write data to the file, fwrite)
4. Receive service data (read file data, fread)
5. Close the Socket (close the file fclose)

After establishing the client, we need to link to the server's program through the ip address and port number. The
ip address is the address of the server's machine. The
port number is the network service program running on the server.
Data can be sent and received after completion

2. Server
1. Establish a Socket (apply for a port for corresponding service requests)
2. Bind port bind (set a port number)
3. Listen to the network port listen (waiting for messages from the customer service side)
4. Wait for the client to connect accept (block to the client link)
5. Receive client data recv (block until there is data to read)
6. Return data send to the client (group match to data transmission completed)
7. Close Socket closesocket

 

Guess you like

Origin blog.csdn.net/guanxunmeng8928/article/details/109181121