| | |
Winsock listen on multiple ports
![]() |
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.
•
•
Join Date: Dec 2005
Posts: 14
Reputation:
Solved Threads: 0
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.
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.
>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.
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.
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?
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?
![]() |
Similar Threads
- Winsock Multi-Client Servers (C++)
- Problem about Bus Topology (Networking Hardware Configuration)
- Spoolsv.exe- high CPU usage (Windows NT / 2000 / XP)
- Computer Ports: What You Should Know to Defend Yourself (Windows tips 'n' tweaks)
Other Threads in the C Forum
- Previous Thread: Noob: needs help with file I/O
- Next Thread: Factorizer
| Thread Tools | Search this Thread |
#include * adobe ansi array arrays asterisks binarysearch centimeter changingto char character cm convert copyimagefile cprogramme creafecopyofanytypeoffileinc createprocess() database dynamic execv feet fgets file floatingpointvalidation fork function getlogicaldrivestrin givemetehcodez grade gtkwinlinux hacking histogram ide inches include incrementoperators infiniteloop input interest intmain() iso kernel keyboard kilometer km license linked linkedlist linux locate looping lowest matrix meter microsoft number oddnumber open opendocumentformat openwebfoundation owf pattern pdf performance pointer posix power probleminc process program programming radix recursion recv recvblocked research reversing segmentationfault sequential single socket socketprograming socketprogramming standard strchr string suggestions systemcall test threads turboc unix urboc user variable voidmain() wab whythiscodecausesegmentationfault windowsapi






