LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-23-2005, 04:51 AM   #1
rajsun
Member
 
Registered: Mar 2005
Posts: 61

Rep: Reputation: 15
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.
 
Old 04-23-2005, 05:14 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
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".

Last edited by Hko; 04-23-2005 at 05:15 AM.
 
Old 04-24-2005, 04:50 PM   #3
Nerox
Member
 
Registered: Jul 2004
Location: Spain
Posts: 111

Rep: Reputation: 20
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
socket programming iiit Programming 2 07-05-2005 04:02 PM
socket programming???? harbir Linux - Networking 2 07-05-2004 02:52 AM
want help in socket programming valib4u *BSD 2 09-11-2003 11:17 PM
Socket Programming cxel91a Programming 4 03-19-2003 10:05 AM
socket programming herambshembekar Programming 3 04-13-2002 03:13 PM


All times are GMT -5. The time now is 11:31 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration