1. ssssoooocccckkkkeeeetttt____aaaacccccccceeeepppptttt((((3333)))) MMMMuuuuddddOOOOSSSS ((((5555 SSSSeeeepppp 1111999999994444)))) ssssoooocccckkkkeeeetttt____aaaacccccccceeeepppptttt((((3333))))
    2. NNNNAAAAMMMMEEEE
    3. socket_accept() - accept a connection on a socket
    4. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
    5. #include <socket_err.h>
    6. int socket_accept( int s, string read_callback,
    7. string write_callback );
    8. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
    9. The argument s is a socket that has been created with
    10. socket_create(3), bound to an address with socket_bind(3),
    11. and is listening for connections after a socket_listen(3).
    12. socket_accept() extracts the first connection on the queue
    13. of pending connections, creates a new socket with the same
    14. properties of s and allocates a new file descriptor for the
    15. socket. If no pending connections are present on the queue,
    16. socket_accept() returns an error as described below. The
    17. accepted socket is used to read and write data to and from
    18. the socket which connected to this one; it is not used to
    19. accept more connections. The original socket s remains open
    20. for accepting further connections.
    21. The argument read_callback is the name of a function for the
    22. driver to call when the new socket (not the accepting
    23. socket) receives data. The write callback should follow
    24. this format:
    25. void read_callback(int fd)
    26. Where fd is the socket which is ready to accept data.
    27. The argument write_callback is the name of a function for
    28. the driver to call when the new socket (not the accepting
    29. socket) is ready to be written to. The write callback should
    30. follow this format:
    31. void write_callback(int fd)
    32. Where fd is the socket which is ready to be written to.
    33. Note: The close_callback of the accepting socket (not the
    34. new socket) is called if the new socket closes unexpectedly,
    35. i.e. not as the result of a socket_close(3) call. The close
    36. callback should follow this format:
    37. void close_callback(int fd)
    38. Where fd is the socket which has closed.
    39. Page 1 (Writen 5/23/97)
    40. ssssoooocccckkkkeeeetttt____aaaacccccccceeeepppptttt((((3333)))) MMMMuuuuddddOOOOSSSS ((((5555 SSSSeeeepppp 1111999999994444)))) ssssoooocccckkkkeeeetttt____aaaacccccccceeeepppptttt((((3333))))
    41. RRRREEEETTTTUUUURRRRNNNN VVVVAAAALLLLUUUUEEEESSSS
    42. socket_accept() returns a non-negative descriptor for the
    43. accepted socket on success. On failure, it returns a
    44. negative value. socket_error(3) can be used on the return
    45. value to get a text description of the error.
    46. EEEERRRRRRRROOOORRRRSSSS
    47. EEFDRANGE Descriptor out of range.
    48. EEBADF Descriptor is invalid.
    49. EESECURITY Security violation attempted.
    50. EEMODENOTSUPP Socket mode not supported.
    51. EENOTLISTN Socket not listening.
    52. EEWOULDBLOCK Operation would block.
    53. EEINTR Interrupted system call.
    54. EEACCEPT Problem with accept.
    55. EENOSOCKS No more available efun sockets.
    56. SSSSEEEEEEEE AAAALLLLSSSSOOOO
    57. socket_bind(3), socket_connect(3), socket_create(3),
    58. socket_listen(3)
    59. Page 2 (Writen 5/23/97)