netdev
[Top] [All Lists]

Re: Opening more than 65000 sockets

To: Yan-Fa Li <yanfali@xxxxxxxxx>
Subject: Re: Opening more than 65000 sockets
From: Sridhar Samudrala <sri@xxxxxxxxxx>
Date: Fri, 29 Mar 2002 13:23:50 -0800 (PST)
Cc: Sridhar Samudrala <sri@xxxxxxxxxx>, Ben Greear <greearb@xxxxxxxxxxxxxxx>, netdev@xxxxxxxxxxx
In-reply-to: <20020329194608.32090.qmail@web13007.mail.yahoo.com>
Sender: owner-netdev@xxxxxxxxxxx
On Fri, 29 Mar 2002, Yan-Fa Li wrote:

> Thanks for the tip.  I tried it out and it doesn't
> appear to work.  It actually fails with a different
> return code EINVAL (22).  Which isn't even a listed
> return code on the connect() man page :(

looks like you are not doing a bind explicitly and allowing the connect()
call to do the auto bind. 
If you want to create 2 sockets with 2 different ip addresses, but the same
port, you should do explicit bind in your client specifying the ip address
and the port. 

Also you need to set SO_REUSEADDR before the call to bind. 

> 
> Anybody else got any more ideas I can try ?
> 
> Here's what I used:
> 
> k=tcp and on=1
> 
> setsockopt(*opensock,k->p_proto,SO_REUSEADDR,&on,sizeof(on));

I am not sure what is k->p_proto. The 2nd argument should be SOL_SOCKET.

> 
> Is this the wrong syntax ?
> 
> Anyway what I really want seems to be SO_REUSEPORT,
> and looking at the source code I see this in
> /usr/src/linux/include/asm/socket.h:
> 
> #define SO_BSDCOMPAT    14
> /* To add :#define SO_REUSEPORT 15 */
> #define SO_PASSCRED     16
> 
> I guess we don't support this feature by design :(
> Any clues on if the support is in the kernel but not
> turned on ?  Or is this something for 2.5 only ?

The names SO_REUSEPORT and SO_REUSEADDR are misleading. SO_REUSEPORT is used
to allow completely duplicate bindings (4-tuple is same) and may not be
supported on all the OSes.

I think SO_REUSEADDR should work in your case.
> 
> Thanks
> 
> Yan
> 
> p.s. this is 2.4.19-pre3aa2 with /dev/epoll-31 patches.
> 
> --- Sridhar Samudrala <sri@xxxxxxxxxx> wrote:
> > On Fri, 29 Mar 2002, Ben Greear wrote:
> > 
> > > 
> > > 
> > > Yan-Fa Li wrote:
> > > 
> > > > It fails in the connect() call.  I get EAGAIN messages.
> > > > They are TCP socekts.  I have my file-max at 1 Million
> > > > files, and ulimit the same.
> > > > 
> > > >>Port space is unique for a protocol (i.e.: TCP or UDP)
> > > >>across a host, independent of interfaces.
> > > >>
> > > 
> > > 
> > > That really looks like a bug or mis-feature to me.  Why
> > > would we want this limitation?  What would be the problems
> > > with fixing it to be per-local-interface?
> > 
> > you can use the socket option SO_REUSEADDR to bind the same port to 
> > multiple sockets, as long as each bind specifies a different local IP
> > address.
> > In this way the port space becomes unique for each local ip address. 
> > 
> > Thanks
> > Sridhar
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Greetings - send holiday greetings for Easter, Passover
> http://greetings.yahoo.com/
> 


<Prev in Thread] Current Thread [Next in Thread>