How to listen on two sockets in the same application
- From: af300wsm@xxxxxxxxx
- Date: 15 Dec 2006 09:13:32 -0800
Hello,
I'm writing a server program that will listen on both IPv4 and IPv6.
Thus, I'm creating two sockets for the two different address families
and will have to listen on both. However, in my past experience on
writing code using listen, the listen call blocks the application until
a connection request is made by some outside entity. Since I've got to
listen on two sockets, how do I accomplish this?
I'm thinking that something like this won't work:
listen( sock1, 5 ); // app is blocked here until connect from client
listen( sock2, 5 );
Is this going to be accomplished by somehow using fcntl to configure
the sockets for non-blocking and then using select on the sockets?
Oh, I don't know if this will add much complexity to things, but I'm
writing all this in C++ and am hoping to wrap the handling of
communication over the two respective address families within
classes/objects. Please bear that in mind with any answers.
Thanks everyone,
Andy
.
- Follow-Ups:
- Re: How to listen on two sockets in the same application
- From: Rainer Weikusat
- Re: How to listen on two sockets in the same application
- From: Pascal Bourguignon
- Re: How to listen on two sockets in the same application
- Prev by Date: Re: finding function name from the function pointer?
- Next by Date: Re: How to listen on two sockets in the same application
- Previous by thread: finding function name from the function pointer?
- Next by thread: Re: How to listen on two sockets in the same application
- Index(es):
Relevant Pages
|