Server socket |
A server socket is an computer communications end point for new incoming connections. The server Berkely sockets will accept incoming connections, handle all lower-level network traffic to finalize the incoming connection and then spawn a new connection that can be used to read from or write to, depending on the code. The server socket itself will still be available to accept other incoming connections.
=Pseudocode example=
#Create a server socket ServerSocket = CreateNewSocket( AF_INET, SOCK_STREAM ); BindSocketToIP( ServerSocket, LOCALIP ); ListenForConnections( ServerSocket ); #Accept incoming connections While( TRUE ) { NewSocket = AcceptConnection( ServerSocket ); While( Data = ReceiveData( NewSocket ) ) { ... } }
AF_INET refers to the socket using a standard network protocol, in this case IPv4. SOCK_STREAM refers to the socket using a standard transport protocol, in this case Transmission Control Protocol. See the article on Berkely socketss for further information.|
|