Subject: Re: Erroneous TCPIP filedescriptors
To: Thomas Page <ThomasP@cat.co.za>
From: Justin C. Walker <justin@apple.com>
List: tech-net
Date: 07/06/1999 10:25:09
> From: Thomas Page <ThomasP@cat.co.za>
> Date: 1999-07-06 08:07:00 -0700
> To: 'NetBSD kernel group' <tech-kern@netbsd.org>,'NetBSD Network group'
> <tech-net@netbsd.org>
> Subject: Erroneous TCPIP filedescriptors
> Delivered-to: tech-net@netbsd.org
> X-Mailer: Internet Mail Service (5.5.1960.3)
>
> I am working with somthing that uses TCPIP to talk to the outside
world, and UDP to
> send messages between several different processes. A 'select'
forms the heart
> of the application, as it waits for the UDP messages, forwards
them to a message
> handler, and for the TCPIP, which waits for a suitable partner to
connect to
> (works OK), then to indicate waiting data. The connection 'accept'
spawns a new
> fd, which is then listened to in the 'select'.
>
> The problem I have is that: after a connection is made, then
control reverts back
> to the main program, and ultimately sits waiting for action in the
'select', as it
> enters the select, the fd for the TCP causes a 'Bad File
Descriptor' from
> strerror(errno).
>
> 1) Is it OK to use select for more than just making connections?
> 2) Is there some other lurking error, I've had 'TCP persistance'
mentioned,
> bearing in mind that the problem is erratic.
>
> Thomas Page
> thomasp@cat.co.za (tompage@hotmail.com) +27 31 560 6556
>
> "I can not be intimidated, bought, or blackmailed. I can only be
inspired."
>
> Unknown 20th century poet
>
>
This could be a bug in your code. On the face of it, nothing else
strikes me. If you have a debugger handy, or using printfs, check
the value of the file descriptor(s) you are passing to select().
To answer your questions:
1) Yes, select() has bit arrays of fd's for "read", "write", and
"exception" events, so that any of these activities are fine to use
with select(). You need to check man pages to be sure you understand
some of the "unusual" ways select() is activated. See also the book
"Unix Network Programming, V1, 2nd Ed.", by Stevens, for a very good
discussion of this routine.
2) See above. TCP Persistence is a very low-level function, and
probably not related to this. My guess is that you are giving the
wrong FD to select, or perhaps using select incorrectly.
Regards,
Justin
--
Justin C. Walker, Curmudgeon-At-Large *
Institute for General Semantics |
Manager, CoreOS Networking | When crypto is outlawed,
Apple Computer, Inc. | Only outlaws
will have crypto.
2 Infinite Loop |
Cupertino, CA 95014 |
*-------------------------------------------------------*--------------------------------------------*