ssssoooocccckkkkeeeetttt____aaaacccccccceeeepppptttt((((3333)))) MMMMuuuuddddOOOOSSSS ((((5555 SSSSeeeepppp 1111999999994444)))) ssssoooocccckkkkeeeetttt____aaaacccccccceeeepppptttt((((3333))))NNNNAAAAMMMMEEEEsocket_accept() - accept a connection on a socketSSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS#include <socket_err.h>int socket_accept( int s, string read_callback,string write_callback );DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNNThe argument s is a socket that has been created withsocket_create(3), bound to an address with socket_bind(3),and is listening for connections after a socket_listen(3).socket_accept() extracts the first connection on the queueof pending connections, creates a new socket with the sameproperties of s and allocates a new file descriptor for thesocket. If no pending connections are present on the queue,socket_accept() returns an error as described below. Theaccepted socket is used to read and write data to and fromthe socket which connected to this one; it is not used toaccept more connections. The original socket s remains openfor accepting further connections.The argument read_callback is the name of a function for thedriver to call when the new socket (not the acceptingsocket) receives data. The write callback should followthis format:void read_callback(int fd)Where fd is the socket which is ready to accept data.The argument write_callback is the name of a function forthe driver to call when the new socket (not the acceptingsocket) is ready to be written to. The write callback shouldfollow this format:void write_callback(int fd)Where fd is the socket which is ready to be written to.Note: The close_callback of the accepting socket (not thenew socket) is called if the new socket closes unexpectedly,i.e. not as the result of a socket_close(3) call. The closecallback should follow this format:void close_callback(int fd)Where fd is the socket which has closed.Page 1 (Writen 5/23/97)ssssoooocccckkkkeeeetttt____aaaacccccccceeeepppptttt((((3333)))) MMMMuuuuddddOOOOSSSS ((((5555 SSSSeeeepppp 1111999999994444)))) ssssoooocccckkkkeeeetttt____aaaacccccccceeeepppptttt((((3333))))RRRREEEETTTTUUUURRRRNNNN VVVVAAAALLLLUUUUEEEESSSSsocket_accept() returns a non-negative descriptor for theaccepted socket on success. On failure, it returns anegative value. socket_error(3) can be used on the returnvalue to get a text description of the error.EEEERRRRRRRROOOORRRRSSSSEEFDRANGE Descriptor out of range.EEBADF Descriptor is invalid.EESECURITY Security violation attempted.EEMODENOTSUPP Socket mode not supported.EENOTLISTN Socket not listening.EEWOULDBLOCK Operation would block.EEINTR Interrupted system call.EEACCEPT Problem with accept.EENOSOCKS No more available efun sockets.SSSSEEEEEEEE AAAALLLLSSSSOOOOsocket_bind(3), socket_connect(3), socket_create(3),socket_listen(3)Page 2 (Writen 5/23/97)
