Socket Objects

A socket is an endpoint of communication—an object through which your application communicates with other Windows Sockets (Winsock) applications across a network. There are sockets on the client and server sides.

The steps used on the client side for communication through sockets are:

  1. Open. The networking application creates a socket for a specific protocol.
  2. Bind. The socket is assigned a name (address). In TCP/IP, the application assigns a port, and may also assign an IP address if the computer is multihomed.
  3. Connect. A connection is established with the server socket, so that send and receive operations can take place. You can connect a socket for which there has been no bind operation, and the binding will take place as part of the connect operation. An explicit bind operation is needed only if a specific port and IP address are needed for the connection.

The steps used on the server side for communication through sockets are:

  1. Open. Create the socket.
  2. Bind. The bind is usually performed on a well-known port.
  3. Listen. Be prepared to accept connections. The listen operation takes place on the kernel level.
  4. Accept. Accept the connection and open a new socket for it. This socket is passed to the application so that it can communicate with the client. The listening socket continues to listen for additional connect requests, so that other accept functions can take place.

For more information about sockets, see MSDN. For details about using sockets with this product, see Socket Implementation in Forefront TMG.


Send comments about this topic to Microsoft

Build date: 11/30/2009

© 2008 Microsoft Corporation. All rights reserved.