tcp_accept

tcp_accept — forks a new TCP socket on the server side to accept a new connection.

Synopsis

tcp_accept (socket)

		

Arguments

socket

A descriptor for a listening socket, as returned by a call to tcp_listen.

Returns

A file descriptor for a new, connected socket.

Description

This function allows a passive, listening socket to accept a connection, by spawning a new socket that maintains the connection. It is essentially the same as the C accept function, but returns a socket descriptor instead of an address.

Example

         CLIENT SIDE:                             SERVER SIDE:

                                           Gamma> tcp_listen(51715);
                                           5
                                           Gamma> tcp_accept(51715);

Gamma> tcp_connect("localhost", 51715);    6
5					

Gamma> fd_write(5, "Hi there");            Gamma> fd_read(6, "Hi there");
8                                          8

See Also

tcp_connect, tcp_listen