Thu, 17 Apr 2014 11:55:36 +0200
removed nonblocking sockets for causing problems and not being necessary
src/game.c | file | annotate | diff | comparison | revisions | |
src/network.c | file | annotate | diff | comparison | revisions | |
src/network.h | file | annotate | diff | comparison | revisions |
--- a/src/game.c Thu Apr 17 11:41:02 2014 +0200 +++ b/src/game.c Thu Apr 17 11:55:36 2014 +0200 @@ -327,12 +327,6 @@ static int recvmove(GameState *gamestate, GameInfo *gameinfo, int opponent) { - if (net_setnonblocking(opponent, 1)) { - printw("Cannot setup nonblocking IO on network socket"); - cbreak(); getch(); - exit(EXIT_FAILURE); - } - struct timeval timeout; while (1) { timecontrol(gamestate, gameinfo); @@ -402,6 +396,9 @@ } else { net_send_code(opponent, NETCODE_DECLINE); } + break; + default: + printw("\nInvalid network request."); } } }
--- a/src/network.c Thu Apr 17 11:41:02 2014 +0200 +++ b/src/network.c Thu Apr 17 11:55:36 2014 +0200 @@ -29,7 +29,6 @@ #include <stdlib.h> #include <string.h> -#include <fcntl.h> #include "network.h" #define new_socket() socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); @@ -132,23 +131,5 @@ } void net_recieve_data(int socket, void *data, size_t len) { - recv(socket, data, len, 0); + recv(socket, data, len, MSG_WAITALL); } - -int net_setnonblocking(int socket, _Bool nonblocking) { - int opts = fcntl(socket, F_GETFL); - if (opts < 0) { - return 1; - } - - if (nonblocking) { - opts |= O_NONBLOCK; - } else { - opts &= ~O_NONBLOCK; - } - if (fcntl(socket, F_SETFL, opts) < 0) { - return 1; - } - - return 0; -}
--- a/src/network.h Thu Apr 17 11:41:02 2014 +0200 +++ b/src/network.h Thu Apr 17 11:55:36 2014 +0200 @@ -74,8 +74,6 @@ uint8_t net_recieve_code(int socket); void net_recieve_data(int socket, void *data, size_t len); -int net_setnonblocking(int socket, _Bool nonblocking); - #ifdef __cplusplus } #endif