I am writing some server programs. I notice that I can only connect to the server with a total of 28232 connections(clients) before I get the errno [99] “Cannot assign requested address” from the client program. I am using the same machine to do both operations. It seems like I am reaching some networking limitation outsie of both programs.The server process has a maximum of 6 theads running(well below the thead limit). The client has two theads. When I add another client machine to the testing I can surpass 28232 connections). What limitation am I reaching on the server machine and how can I overcome this limitation. Again when I add a client machine to the testing, I can achieve more than 28232.
System Setup:
SUSE 11.1 64 bits
ulimit nofile=150000
What makes you think this is a server limitation? I do not know that it
is not, but you stated yourself that you could get more than 28232
connections (on the server) by adding another client.
Good luck.
uans wrote:
> I am writing some server programs. I notice that I can only connect to
> the server with a total of 28232 connections(clients) before I get the
> errno [99] “Cannot assign requested address” from the client program. I
> am using the same machine to do both operations. It seems like I am
> reaching some networking limitation outsie of both programs.The server
> process has a maximum of 6 theads running(well below the thead limit).
> The client has two theads. When I add another client machine to the
> testing I can surpass 28232 connections). What limitation am I reaching
> on the server machine and how can I overcome this limitation. Again when
> I add a client machine to the testing, I can achieve more than 28232.
>
> System Setup:
> SUSE 11.1 64 bits
> ulimit nofile=150000
>
> THKS,
> uans
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
Well, since I am running the server and client program on one machine until 28232 connections is reached, what eles could it be.It has to be on the server machine. I hope I am making this clear!
I once wrote a server program, it prefer a long connection, I mean, accept once then loop read/write, but if client only give once read/write, it can close the client fd no problem. Then I wrote a client a program but it prefer short connection, that is, connect/write/read/close, then the client loop do connect/read/write about 1 millioin times. I found after about 28231 connection, the client exeception with error “Cannot assign requested address - connect(2)”. if I change the client model to long connection, or I change the server model to process only short connection, that is accept/read/write/close the client fd, all is ok, what’s wrong? server and client code attached.
Here was the reply:
The machine ran out of dynamic ports to assign as the source port for the outbound connection. Either get the administrator of the machine to allow a larger range of source ports or ‘bind’ to a random source port chosen over a large range (say, 34000-60000) yourself.
My question is where can I inlarge the port size limit at?
Yes, that is likely the problem, but it is, as mentioned, still a client
problem. The limit is on the number of OUTBOUND connections. Anyway, if
you really want to do it Google for:
/proc/sys/net/ipv4/ip_local_port_range
The following came up for me as one runtime option, though its setting
will not last across reboots. I have not found where to set the value
permanently for persistence:
uans wrote:
> I did a search and here what I found:
>
> User wrote:
>
> I once wrote a server program, it prefer a long connection, I mean,
> accept once then loop read/write, but if client only give once
> read/write, it can close the client fd no problem. Then I wrote a client
> a program but it prefer short connection, that is,
> connect/write/read/close, then the client loop do connect/read/write
> about 1 millioin times. I found after about 28231 connection, the client
> exeception with error “Cannot assign requested address - connect(2)”. if
> I change the client model to long connection, or I change the server
> model to process only short connection, that is accept/read/write/close
> the client fd, all is ok, what’s wrong? server and client code
> attached.
>
> Here was the reply:
>
> The machine ran out of dynamic ports to assign as the source port for
> the outbound connection. Either get the administrator of the machine to
> allow a larger range of source ports or ‘bind’ to a random source port
> chosen over a large range (say, 34000-60000) yourself.
>
> My question is where can I inlarge the port size limit at?
>
> THKS,
> uans
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
ab@novell.com wrote:
> Yes, that is likely the problem, but it is, as mentioned, still a client
> problem. The limit is on the number of OUTBOUND connections. Anyway, if
> you really want to do it Google for:
>
> /proc/sys/net/ipv4/ip_local_port_range
>
> The following came up for me as one runtime option, though its setting
> will not last across reboots. I have not found where to set the value
> permanently for persistence:
>
> http://docs.sun.com/source/817-2180-10/pt_chap6.html
>
> Good luck.
>
>
>
>
>
> uans wrote:
>> I did a search and here what I found:
>
>> User wrote:
>
>> I once wrote a server program, it prefer a long connection, I mean,
>> accept once then loop read/write, but if client only give once
>> read/write, it can close the client fd no problem. Then I wrote a client
>> a program but it prefer short connection, that is,
>> connect/write/read/close, then the client loop do connect/read/write
>> about 1 millioin times. I found after about 28231 connection, the client
>> exeception with error “Cannot assign requested address - connect(2)”. if
>> I change the client model to long connection, or I change the server
>> model to process only short connection, that is accept/read/write/close
>> the client fd, all is ok, what’s wrong? server and client code
>> attached.
>
>> Here was the reply:
>
>> The machine ran out of dynamic ports to assign as the source port for
>> the outbound connection. Either get the administrator of the machine to
>> allow a larger range of source ports or ‘bind’ to a random source port
>> chosen over a large range (say, 34000-60000) yourself.
>
>> My question is where can I inlarge the port size limit at?
>
>> THKS,
>> uans
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
That seemed to do it. My goal was 50k of client. The limitation is only net.ipv4.ip_local_port_range max. Just so you know, the server can handle 30k 0f burst client with 5k concurrent client connections without any interruption to the dispatching payload.
Last note, it was the client program on the server machine that was issuing the errno[99] not the server program on the server machine. This should make sense to you now.