Servers and Clients

来源:互联网 发布:怎么投诉淘宝店铺盗图 编辑:程序博客网 时间:2024/05/23 01:13

Servers and Clients(from msdn)

There are two distinct types of socket network applications: Server and Client.

Servers and Clients have different behaviors; therefore, the process of creating them is different. What follows is the general model for creating a streaming TCP/IP Server and Client.

Server

 

  1. Initialize Winsock.
  2. Create a socket.
  3. Bind the socket.
  4. Listen on the socket for a client.
  5. Accept a connection from a client.
  6. Receive and send data.
  7. Disconnect.

Client

 

  1. Initialize Winsock.
  2. Create a socket.
  3. Connect to the server.
  4. Send and receive data.
  5. Disconnect.