diff options
-rw-r--r-- | 091socket.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/091socket.cc b/091socket.cc index b5afa26c..91d574e6 100644 --- a/091socket.cc +++ b/091socket.cc @@ -55,6 +55,11 @@ case _OPEN_SERVER_SOCKET: { socket_t* server_socket(int portno) { socket_t* result = new socket_t; result->fd = socket(AF_INET, SOCK_STREAM, 0); + if (result->fd < 0) { + raise << "Failed to create server socket.\n" << end(); + delete result; + return NULL; + } int dummy = 0; setsockopt(result->fd, SOL_SOCKET, SO_REUSEADDR, &dummy, sizeof(dummy)); result->addr.sin_family = AF_INET; |