fix centos gcc 4.4.7 compile error

This commit is contained in:
ideawu 2015-11-13 20:19:45 +08:00
parent 7350fa8373
commit f435ee41fc
3 changed files with 7 additions and 5 deletions

View File

@ -1,5 +1,5 @@
all:
gcc -O2 -o server server.c
gcc -std=c99 -O2 -o server server.c
gcc -O2 -o client client.c

View File

@ -28,7 +28,7 @@ int main(int argc, char **argv){
socklen_t optlen;
int connections = 0;
bzero(&addr, sizeof(addr));
memset(&addr, sizeof(addr), 0);
addr.sin_family = AF_INET;
inet_pton(AF_INET, ip, &addr.sin_addr);

View File

@ -34,9 +34,11 @@ int main(int argc, char **argv){
int server_socks[MAX_PORTS];
for(int i=0; i<MAX_PORTS; i++){
int port = base_port + i;
bzero(&addr, sizeof(addr));
int i;
int port;
for(i=0; i<MAX_PORTS; i++){
port = base_port + i;
memset(&addr, sizeof(addr), 0);
addr.sin_family = AF_INET;
addr.sin_port = htons((short)port);
inet_pton(AF_INET, ip, &addr.sin_addr);