211

Sockets
Server

  • A server accepts incomming connections from clients by

    1. Creating a socket
    2. Binding the socket to a specified port
    3. Setting the socket to listen (act as a server), and then
    4. Waiting to accept incomming connections

  • For example

      socket( S, PF_INET, SOCK_STREAM, (getprotobyname('tcp'))[2] );
      bind( S, sockaddr_in( $port, INADDR_ANY ) );
      listen( S, SOMAXCONN );
      accept( C, S );