tcp_accept
tcp_accept — forks a new TCP socket on the server side to accept a new
connection.
tcp_accept (socket)
socketA descriptor for a listening socket, as returned by a call to
tcp_listen.
A file descriptor for a new, connected socket.
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.
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