int network_shutdown(t_net *net) {
+ int channel;
+
+ for(channel=0;channel<MAX_CONNECTIONS;channel++)
+ if(net->connection[channel].status&C_SOCKET)
+ close(net->connection[channel].fd);
+
if(close(net->l_fd)==-1) {
perror("[network] close call");
return N_ERROR;
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;
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;
}