Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

UDP sockets and select()
I wrote a program that created a UDP socket (SOCKET_DGRAM) with the
expectation of reading UDP datagrams from it but select() claims that the
socket was never ready for reading.  Now, I _know_ there was data to be read
because replacing the select() call with a synchronous recvfrom() call
returns data!

So, what's up?  Why doesn't select() work connectionless sockets?  Is
this the same on all UNIX systems?  I'm trying this on Linux 2.4.21.
Thanks...




Report this thread to moderator Post Follow-up to this message
Old Post
Just Another Victim of the Ambient Morality
09-15-04 01:59 PM


Re: UDP sockets and select()
"Just Another Victim of the Ambient Morality" <ihatespam@rogers.com> writes:

>     I wrote a program that created a UDP socket (SOCKET_DGRAM) with the
> expectation of reading UDP datagrams from it but select() claims that the
> socket was never ready for reading.  Now, I _know_ there was data to be re
ad
> because replacing the select() call with a synchronous recvfrom() call
> returns data!
>
>     So, what's up?  Why doesn't select() work connectionless sockets?  Is
> this the same on all UNIX systems?  I'm trying this on Linux 2.4.21.

It has always worked for me on all Unixes I've tried.  Post some code
demonstrating the problem.

--
Måns Rullgård
mru@mru.ath.cx

Report this thread to moderator Post Follow-up to this message
Old Post
Måns Rullgård
09-15-04 01:59 PM


Re: UDP sockets and select()
"Just Another Victim of the Ambient Morality" <ihatespam@rogers.com> wrote in message news:
<zKS1d.257$RTE1.109@news01.bloor.is.net.cable.rogers.com>...
> I wrote a program that created a UDP socket (SOCKET_DGRAM) with the
> expectation of reading UDP datagrams from it but select() claims that the
> socket was never ready for reading.  Now, I _know_ there was data to be re
ad
> because replacing the select() call with a synchronous recvfrom() call
> returns data!
>
>     So, what's up?  Why doesn't select() work connectionless sockets?  Is
> this the same on all UNIX systems?  I'm trying this on Linux 2.4.21.
>     Thanks...

The select() system call works just fine with UDP on linux.  Trust me,
its not the kernel.  Its your code.

The number one select() mistake that everyone makes at one time or
another is incorrectly setting the first agument - the maximum fd
*plus one*.  Check that first.

dv

Report this thread to moderator Post Follow-up to this message
Old Post
Dirty Vicar
09-17-04 01:39 AM


Re: UDP sockets and select()
dv is right.

I've also posted a message to talk about this, and I realized that in
my implementation, I did put *1* in the first arguement on the
select(). If you can take a look at the man page, you will figure out
more. =)

- tikviva

dirtyvicar@hotmail.com (Dirty Vicar) wrote in message news:<b90dfd06.0409160810.4f56546e@po
sting.google.com>...
> "Just Another Victim of the Ambient Morality" <ihatespam@rogers.com> wrote
 in message news:<zKS1d.257$RTE1.109@news01.bloor.is.net.cable.rogers.com>..
. 
>
> The select() system call works just fine with UDP on linux.  Trust me,
> its not the kernel.  Its your code.
>
> The number one select() mistake that everyone makes at one time or
> another is incorrectly setting the first agument - the maximum fd
> *plus one*.  Check that first.
>
> dv

Report this thread to moderator Post Follow-up to this message
Old Post
tikviva
09-19-04 08:58 PM


Re: UDP sockets and select()
"Dirty Vicar" <dirtyvicar@hotmail.com> wrote in message
news:b90dfd06.0409160810.4f56546e@posting.google.com...
> "Just Another Victim of the Ambient Morality" <ihatespam@rogers.com> wrote
in message news:<zKS1d.257$RTE1.109@news01.bloor.is.net.cable.rogers.com>...
 
the 
read 
Is 
>
> The select() system call works just fine with UDP on linux.  Trust me,
> its not the kernel.  Its your code.
>
> The number one select() mistake that everyone makes at one time or
> another is incorrectly setting the first agument - the maximum fd
> *plus one*.  Check that first.

Ah, it turns out that that was, indeed, my problem.  Thanks for the
help!

I've got another question but I'll ask that in its own thread...



Report this thread to moderator Post Follow-up to this message
Old Post
Just Another Victim of the Ambient Morality
09-21-04 09:00 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Unix Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:13 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.