LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Help me ... about Socket programming.. (https://www.linuxquestions.org/questions/programming-9/help-me-about-socket-programming-316317/)

rajsun 04-23-2005 04:51 AM

Help me ... about Socket programming..
 
Hi all,
Can i open two listening sockets to accept further new connections from other process, in a process....??? By using same IP address and two diffrent port... on a single a machine...

With Regard
RajSun.

Hko 04-23-2005 05:14 AM

Yes, either fork() another process listening to the other port to prevent blocking on accept() one the first port, or use non-blocking sockets, and use select() to block until a new connection request arrives on either socket.

See "man select_tut" and "man select".

Nerox 04-24-2005 04:50 PM

You can open so many listening sockets as ports exist. There are 2^16 = 65536 different ports, so in theory you can open up to 65536 listening sockets, but don't worry, i think you cannot run such an amount of processes on your computer at the same time (at least you will be running other processes, so you can never reach that number). You can even open two sockets of different protocol families using the same port; e.g: opening an UDP socket and a TCP socket, but remember that UDP sockets can't listen.


All times are GMT -5. The time now is 12:06 PM.