UDP + select problem

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?
 
M

mark_bluemel

Manuel said:
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>
 
D

Dave Vandervies

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,737
Latest member
Georgeengab

Latest Threads

Top