M
Manuel
Hi to all,
I need a server for handle tcp and udp connections.
I have write code like follow:
if( (listenfd = tcp_listen(PORT)) == -1)
err_sys("TCP socket error");
if( (lisudpfd = udp_listen(PORT)) == -1)
err_sys("UDP socket error");
FD_ZERO(&allset);
FD_SET(listenfd, &allset);
FD_SET(lisudpfd, &allset);
for ( ; ; ) {
rset = allset;
if( (ready = select(maxfd+1, &rset, NULL, NULL, NULL)) < 0 )
err_sys("select error");
if( FD_ISSET(listenfd, &rset) ) {
/* accept TCP connection */
}
if (FD_ISSET(lisudpfd, &rset)) {
/* handling UDP connection */
printf("!!!!!!!!!!\n");
server_echo_udp(lisudpfd, (struct sockaddr *) &cliaddr,
sizeof(cliaddr));
}
for( i = 0; i <= maxi; i++ ) {
/* handle TCP clients */
}
}
The function server_echo_udp work if invoked after the udp_listen but in
the select it never run. The select handle the tcp sockets fine.
Suggestion?
I need a server for handle tcp and udp connections.
I have write code like follow:
if( (listenfd = tcp_listen(PORT)) == -1)
err_sys("TCP socket error");
if( (lisudpfd = udp_listen(PORT)) == -1)
err_sys("UDP socket error");
FD_ZERO(&allset);
FD_SET(listenfd, &allset);
FD_SET(lisudpfd, &allset);
for ( ; ; ) {
rset = allset;
if( (ready = select(maxfd+1, &rset, NULL, NULL, NULL)) < 0 )
err_sys("select error");
if( FD_ISSET(listenfd, &rset) ) {
/* accept TCP connection */
}
if (FD_ISSET(lisudpfd, &rset)) {
/* handling UDP connection */
printf("!!!!!!!!!!\n");
server_echo_udp(lisudpfd, (struct sockaddr *) &cliaddr,
sizeof(cliaddr));
}
for( i = 0; i <= maxi; i++ ) {
/* handle TCP clients */
}
}
The function server_echo_udp work if invoked after the udp_listen but in
the select it never run. The select handle the tcp sockets fine.
Suggestion?