tcp_create_listener()

A C process can listen for connection requests generated by client processes by calling the C function tcp_create_listener(), as shown by the following program fragment:

     int Port,Service;
     char *Host;
     
     if (tcp_create_listener(0, &Port,&Host,&Service) != 0)
             ... an error occurred.
     

The C function tcp_create_listener() is used by a C server to create a listener (Service). A passive socket is used to accept connection requests. It returns the port and hostname in Port and Host arguments respectively. The first argument specifies a fixed port number to listen on. If it is zero, as in this example, then a dynamic port number is allocated. The Service is used with later calls to the C function tcp_accept() to accept a connection request. A connection request is detected using the C function tcp_select().

The example program c_server.c illustrates the use of this function (see ipc-tcp-exa).