--- a/src/network.c Thu Apr 17 11:55:36 2014 +0200 +++ b/src/network.c Thu Apr 17 12:16:14 2014 +0200 @@ -126,8 +126,11 @@ uint8_t net_recieve_code(int socket) { uint8_t code; - recv(socket, &code, sizeof(uint8_t), 0); - return code; + if (recv(socket, &code, sizeof(code), 0) == sizeof(code)) { + return code; + } else { + return NETCODE_CONNLOST; + } } void net_recieve_data(int socket, void *data, size_t len) {