Connecting Tech Pros Worldwide Help | Site Map

UDP + select problem

Manuel
Guest
 
Posts: n/a
#1: Jan 8 '07
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?
mark_bluemel@pobox.com
Guest
 
Posts: n/a
#2: Jan 8 '07

re: UDP + select problem



Manuel wrote:
Quote:
Hi to all,
I need a server for handle tcp and udp connections.
That's not specific to the C programming language - you'd do better
asking in a more suitable group. Perhaps one of the comp.unix
newsgroups?

<Off-topic>
IMHO, the best references for this sort of thing, complete with working
examples, are W Richard Stevens' "Unix Network Programming" texts
published by Prentice-Hall.
If you want to write this sort of code, you should get copies.
</Off-topic>

Dave Vandervies
Guest
 
Posts: n/a
#3: Jan 8 '07

re: UDP + select problem


In article <Vssoh.102699$uv5.1369738@twister1.libero.it>,
Manuel <behind@vanilla.skywrote:
Quote:
>Hi to all,
>I need a server for handle tcp and udp connections.
This is beyond the scope of the C programming language and therefore
off-topic for comp.lang.c.

Since the code you posted looks POSIXish, comp.unix.programmer might be
a good next stop. (Reading their FAQ first is probably a good idea.)


dave

--
Dave Vandervies dj3vande@csclub.uwaterloo.ca
I used to think -- "Hey, Java is safe. All it can do is play in the sandbox."
Darn thing went and threw a handful of sand in my face.
--Dann Corbit in comp.lang.c
Closed Thread