* @brief Accepts incoming connections on a UNIX domain stream server socket. * * @param flags Flags for Linux' `accept4()`; useless on other implementations. */
| 110 | * @param flags Flags for Linux' `accept4()`; useless on other implementations. |
| 111 | */ |
| 112 | unix_stream_client* unix_stream_server::accept(int flags) { |
| 113 | int cfd; |
| 114 | |
| 115 | if (sfd == -1) |
| 116 | throw socket_exception( |
| 117 | __FILE__, __LINE__, |
| 118 | "unix_stream_server::accept: Socket not set up yet!", false); |
| 119 | |
| 120 | unix_stream_client* client = new unix_stream_client; |
| 121 | |
| 122 | cfd = accept_unix_stream_socket(sfd, flags); |
| 123 | |
| 124 | if (cfd < 0) { |
| 125 | if (is_nonblocking && errno == EWOULDBLOCK) |
| 126 | return nullptr; |
| 127 | else |
| 128 | throw socket_exception(__FILE__, __LINE__, |
| 129 | "unix_stream_server::accept: Error at " |
| 130 | "accepting new connection!"); |
| 131 | } |
| 132 | |
| 133 | client->sfd = cfd; |
| 134 | |
| 135 | return client; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * @brief Accepts an incoming connection on a UNIX domain stream server socket |
nothing calls this directly
no test coverage detected