+int network_connect(t_net *net,int channel) {
+
+ if(net->connection[channel].status&C_IN_USE) {
+ printf("[network] connect failed, channel %02d in use\n",channel);
+ return N_E_IN_USE;
+ }
+ if(!(net->connection[channel].status&C_INFO_A)) {
+ printf("[network] connect failed, missing configuration for channel %02d",
+ channel);
+ return N_E_NO_INFO;
+ }
+
+ /* try connect & return result */
+ net->connection[channel].status|=C_IN_USE;
+ return(network_manage_connection(net)); /* could be other channel too */
+}
+
+int network_close(t_net *net,int channel) {
+
+ if(!(net->connection[channel].status&C_ESTABL)) {
+ printf("[network] close failed, channel %02d not active",channel);
+ return N_E_NC;
+ }
+
+ net->connection[channel].status|=C_HANGUP;
+ return(network_manage_connection(net)); /* could be other channel too */
+}
+
+int network_set_connection_info(t_net *net,int channel,char *ip,int port) {
+
+ if(net->connection[channel].status&C_IN_USE) {
+ printf("[network] set connection failed, channel %02d in use\n",channel);
+ return N_E_IN_USE;
+ }
+
+ strncpy(net->connection[channel].ip,ip,IP_DIGITS);
+ net->connection[channel].port=port;
+ net->connection[channel].status|=C_INFO_A;
+
+ return N_SUCCESS;
+}
+
+int network_select(t_net *net,int channel) {
+
+ int mask;
+
+ if(channel==MAX_CONNECTIONS) mask=0xffffffff;
+ else mask=(1<<channel);
+ net->sendmask|=mask;
+
+ return N_SUCCESS;
+}
+
+int network_deselect(t_net *net,int channel) {
+
+ int mask;
+
+ if(channel==MAX_CONNECTIONS) mask=0;
+ else mask=~(1<<channel);
+ net->sendmask&=mask;
+
+ return N_SUCCESS;
+}
+