src/network.c

changeset 46
4dcfb4c58b6d
parent 45
e14a1d9aa91d
child 48
0cedda2544da
equal deleted inserted replaced
45:e14a1d9aa91d 46:4dcfb4c58b6d
124 send(socket, pkg, len+1, 0); 124 send(socket, pkg, len+1, 0);
125 } 125 }
126 126
127 uint8_t net_recieve_code(int socket) { 127 uint8_t net_recieve_code(int socket) {
128 uint8_t code; 128 uint8_t code;
129 recv(socket, &code, sizeof(uint8_t), 0); 129 if (recv(socket, &code, sizeof(code), 0) == sizeof(code)) {
130 return code; 130 return code;
131 } else {
132 return NETCODE_CONNLOST;
133 }
131 } 134 }
132 135
133 void net_recieve_data(int socket, void *data, size_t len) { 136 void net_recieve_data(int socket, void *data, size_t len) {
134 recv(socket, data, len, MSG_WAITALL); 137 recv(socket, data, len, MSG_WAITALL);
135 } 138 }

mercurial