Winsock listen on multiple ports

Reply

Join Date: Dec 2005
Posts: 14
Reputation: osean is an unknown quantity at this point 
Solved Threads: 0
osean osean is offline Offline
Newbie Poster

Winsock listen on multiple ports

 
0
  #1
Mar 6th, 2006
Can someone give me an example on how to listen on multiple ports with Winsock? I have been trying for hours with no luck..
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: Winsock listen on multiple ports

 
0
  #2
Mar 6th, 2006
I haven't done it, but I dont think that it should be much different than listening in a single port...Just create SocketNumber1 and bind it to portnumber1, create SocketNumber2 and bind it to portnumber2, and listen on both sockets. Depending on the Socket I/O Model, you will get which request comes to which socket. Give what you have tried so far, and maybe someone will be able to see what you are doing wrong.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 14
Reputation: osean is an unknown quantity at this point 
Solved Threads: 0
osean osean is offline Offline
Newbie Poster

Re: Winsock listen on multiple ports

 
0
  #3
Mar 6th, 2006
Thanks for the reply,
I can do it easily using the method you described (create a socket for each individual port i want to listen on).. is there an easier way? i want to be able to listen on 15+ ports and that means i'm going to have to create an idividual socket for each port i want to listen on, so 15+ sockets.. it would be nice if i could just use one socket for listening on several ports.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,603
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 713
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Winsock listen on multiple ports

 
0
  #4
Mar 6th, 2006
>it would be nice if i could just use one socket for listening on several ports.
Too bad it doesn't work that way. You have to have multiple sockets to listen on multiple ports, whether it be something like an array of sockets in the thread, or multiple threads that work with a single socket.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: Winsock listen on multiple ports

 
0
  #5
Mar 6th, 2006
I am not 100% sure about this, but I dont think you can do that. Maybe someone who has more experiance in network programming will disagree, but out of the Socket Models that I have used upto now, when you get a connection request, you can only tell to what socket is that request made. There is no way of differentiating from which port-number.

By the way, why do you need 15 different port numbers? That means you are trying to use 15 different protocols. What are you trying to do?
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 14
Reputation: osean is an unknown quantity at this point 
Solved Threads: 0
osean osean is offline Offline
Newbie Poster

Re: Winsock listen on multiple ports

 
0
  #6
Mar 6th, 2006
I was messing around with a client-server p2p application, I guess I will just go with the first method suggested (creating a socket for each port), thanks.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC