X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;f=src%2Fnetwork.c;h=9ccb2b57b1ecf99e8b271f70abcfab3b98ffe349;hb=2fb65b9beceb0945b593e28332507aa1b7c3fd90;hp=3e9fe39b8176dfe10a4d0ea38478f9b0936c9105;hpb=d3c5d3d150e9f9368b2ba9f8d0f957dbb58c14d4;p=my-code%2Fivac.git diff --git a/src/network.c b/src/network.c index 3e9fe39..9ccb2b5 100644 --- a/src/network.c +++ b/src/network.c @@ -53,6 +53,12 @@ int network_init(t_net *net) { int network_shutdown(t_net *net) { + int channel; + + for(channel=0;channelconnection[channel].status&C_SOCKET) + close(net->connection[channel].fd); + if(close(net->l_fd)==-1) { perror("[network] close call"); return N_ERROR; @@ -95,9 +101,11 @@ int network_manage_connection(t_net *net) { perror("[network] socket call"); return N_ERROR; } + net->connection[i].status|=C_SOCKET; } - if(!net->connection[i].status&C_ESTABL) { + if((!net->connection[i].status&C_ESTABL)&& + (net->connection[i].status&C_SOCKET)) { memset(&addr,0,sizeof(struct sockaddr)); addr.sin_family=AF_INET; @@ -115,6 +123,7 @@ int network_manage_connection(t_net *net) { printf("[network] established connection to %s port %d on channel %d\n", net->connection[i].ip,net->connection[i].port,i); + net->connection[i].status|=C_ESTABL; }