c - Is the new connected socket returned by accept() always bound to the same port as the listening socket? -


i tested on machine creating new connections until failure. on machine new connect()/accept() requests fail* @ near 700 socket connections (sock_stream); @ client/server respectively, on loopback ip address. socket file descriptor returned accept(), far, bound same port listening socket.

my question - if behaviour true machines why accept() limiting connections creating connected sockets bound same port listening socket? couldn't number of connections server can make increased if new sockets bound random ports (like connect() does)?

also, why accept(sock_fd, null, null) failing "efault - addr argument not in writable part of user address space." after 700 successful iterations of same call?

similarly, why does, connect() fail "efault - socket structure address outside user's address space." after 700 successful iterations of same call?

* efault - bad address (after both accept()/connect()).

when listening, connections have same port in accept end of connection (that used identifier in order establish connection).

the local port number connecting part if not defined bind() can anything. localhost device, numbers can recycled fast on os, since there no real need lingering state of tcp.

when comes having many connections on same time, amount of connections possible limited resources in operating system per process. unix/linux, limit can adjusted, put not advised make amount of fds higher default if using select(), since libc size of fdset matches default number of filedescriptors available per process. 1 trick around create socket, fork out children , let children call accept(). each children can have many connections (apache , squid use kind of model), increasing total amount of connections possible on same server port.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -