473,378 Members | 1,449 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

UDP + select problem

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?
Jan 8 '07 #1
2 2253

Manuel wrote:
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>

Jan 8 '07 #2
In article <Vs**********************@twister1.libero.it>,
Manuel <be****@vanilla.skywrote:
>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 dj******@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
Jan 8 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: D. Shifflett | last post by:
Hi all, I am having trouble with a program that ran fine on Python 2.0 (#0, Mar 1 2001, 01:47:55) on linux2 but will not work on Python 2.3.2 (#1, Oct 8 2003, 17:33:47) on linux2
2
by: RanDeep | last post by:
I have two nodes that both exist underneath the root node. They are linked, however, in the sense that one of the nodes contains a copy of an id that is used to refer to the other. However, when I...
3
by: Dennis M. Marks | last post by:
I have a problem with the following code. It generates a <FORM><SELECT><OPTION> list. There is no problem in the generating. The problem is in the execution as follows. It works fine in Mac IE...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
1
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
2
by: areef.islam | last post by:
Hi, I am kinda new to javascript and I am having this problem with selecting multiple options from a select tag. Hope someone can help me out here. here is my code...
3
by: imrantbd | last post by:
This is my first problem.Please help me. I have the following code: <head> <script language="JavaScript"> function addSrcToDestList() { destList1 = window.document.forms.destList; srcList...
13
by: PinkBishop | last post by:
I am using VS 2005 with a formview control trying to insert a record to my access db. The data is submitted to the main table no problem, but I need to carry the catID to the bridge table...
2
by: djnokturnal | last post by:
Hey guys / gals, First time posting and of course I am sure it is something that has been answered 100 times but for some reason I just cant find the answer :) First off here is the structure...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.