netdev
[Top] [All Lists]

Re: Opening more than 65000 sockets

To: Sridhar Samudrala <sri@xxxxxxxxxx>
Subject: Re: Opening more than 65000 sockets
From: Yan-Fa Li <yanfali@xxxxxxxxx>
Date: Fri, 29 Mar 2002 13:28:27 -0800 (PST)
Cc: netdev@xxxxxxxxxxx
In-reply-to: <Pine.LNX.4.21.0203291257300.1981-100000@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: owner-netdev@xxxxxxxxxxx
Thanks again.  Ok I tried your suggestion but that
didn't work either.  Here's the offending code fragment, pardon
the fugly coding:

addr.sin_family = AF_INET;
addr.sin_port = 0;
he=gethostbyname(localint);
addr.sin_addr.s_addr = ((unsigned long*) (he->h_addr_list[0]))[0];
setsockopt(*opensock,k->p_proto,SO_REUSEADDR,&on,sizeof(on));
bind(*opensock, (struct sockaddr *)&addr,sizeof(addr));
if (connect(*opensock, (struct sockaddr *) & server,        
sizeof(server)) <0) {
....
}

Now, I get this error code on connect: EAGAIN (11)

So that doesn't apear to work either.  Am I still coding
this wrong ?   It fails at exactly the same number of sockets
as all my previous tries.

Y

--- Sridhar Samudrala <sri@xxxxxxxxxx> wrote:
> 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.
> > 


__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - send holiday greetings for Easter, Passover
http://greetings.yahoo.com/

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