diff --git a/server1/server b/server1/server index d866659..bd1fd71 100755 Binary files a/server1/server and b/server1/server differ diff --git a/server1/server.cpp b/server1/server.cpp index e310cd9..bd72f74 100644 --- a/server1/server.cpp +++ b/server1/server.cpp @@ -211,12 +211,14 @@ void log(std::string msg) { // Returns file descriptor for server socket int start_socket() { + int option = 1; int server_socket = socket(AF_INET, SOCK_STREAM, 0); + setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option)); + sockaddr_in server_address; server_address.sin_family = AF_INET; server_address.sin_port = htons(PORT); server_address.sin_addr.s_addr = INADDR_ANY; - bind(server_socket, (struct sockaddr*)&server_address, sizeof(server_address)); if (errno == 98) { @@ -353,6 +355,12 @@ int main() { int server_socket = start_socket(); + if (server_socket == -1) { + getch(); + endwin(); + return 3; + } + log("Socket created\0"); // Create thread to read commands