* @brief Set up a server socket. * * If the zero-argument constructor was used, this method * initializes a server socket for TCP/IP communication. * * @param bindhost The address the server should listen on * @param bindport The port the server should listen on * @param proto_osi3 The protocol: `LIBSOCKET_IPv4/LIBSOCKET_IPv6` * @param flags Flags for `socket(2)` */
| 103 | * @param flags Flags for `socket(2)` |
| 104 | */ |
| 105 | void inet_stream_server::setup(const char* bindhost, const char* bindport, |
| 106 | int proto_osi3, int flags) { |
| 107 | if (sfd != -1) |
| 108 | throw socket_exception(__FILE__, __LINE__, |
| 109 | "inet_stream_server::inet_stream_server() - " |
| 110 | "already bound and listening!", |
| 111 | false); |
| 112 | if (bindhost == 0 || bindport == 0) |
| 113 | throw socket_exception(__FILE__, __LINE__, |
| 114 | "inet_stream_server::inet_stream_server() - at " |
| 115 | "least one bind argument invalid!", |
| 116 | false); |
| 117 | if (-1 == (sfd = create_inet_server_socket( |
| 118 | bindhost, bindport, LIBSOCKET_TCP, proto_osi3, flags))) |
| 119 | throw socket_exception(__FILE__, __LINE__, |
| 120 | "inet_stream_server::inet_stream_server() - " |
| 121 | "could not create server socket!"); |
| 122 | |
| 123 | host = string(bindhost); |
| 124 | port = string(bindport); |
| 125 | |
| 126 | is_nonblocking = flags & SOCK_NONBLOCK; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * @brief Set up a server socket. |
nothing calls this directly
no test coverage detected