Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear Sir,

I have a project in which I have to listen more than 100 ports in VB.net.
I m little bit confused whether to listen these port on single socket through multithreading or to listen these port on individual socket.

Also data occurance is in seconds. And I dont want to miss any data as it is very critical.

Please suggest some solution for this.
Posted

100 posts?? OK, that's weird. I've never heard of any application that listens to 100 ports at the same time, nor any situation where it's justified.

You might want to spell out EXACTLY what is going on with these 100 ports. Why do you think you have to use 100 ports? How much data is coming from a remote device at one time?

Only one thing can listen on a port at a time, so this doesn't make a lot of sense.
 
Share this answer
 
Dave's right - we need more information... There has to be a better way. How about listening on a single port and accepting multiple (100 or more) connections? That seems like the right way to go to me. But in short - you can't listen to 100 ports with a single socket. You'll need 100 sockets. If that's what you really want to do.

Why not check out my article: Reusable multithreaded TCP client and server classes with example project in VB.NET

I think with this, you will likely be able to do what you need.

- Pete
 
Share this answer
 
v2
Comments
vinaysom 10-May-13 9:48am    
thanks a lot sir,
Actually my project is related to fetch data from remote terminal unit situated around 500 kms away. these units sends data through GPRS to a public ip where i have to get this data and also acknowledge the remote unit with some message. After every 4-5 seconds the next data will arrive on the server. So pls suggest the solution for this..
pdoxtader 10-May-13 10:18am    
This really isn't enough information... And you will need to attempt to write the code yourself and then come to us if you get stuck. I can't write it for you. Do you have 100 of these in the field, all trying to talk to your public IP on a different port? How does the data arrive? XML? You just need to give us more... or failing that, hire a consultant to handle it for you.
vinaysom 12-May-13 12:01pm    
Dear Sir,
Actually there are 96 microcontroller based remote terminal units situated on water delevery tanks with GPRS activated SIM through which they are sending data to base station on a specific port (from 32001 to 32096) where I am listening these ports on individual socket. But due to fast occurance of data (4-5) the connection between RTus and server are lost. And again these RTUs connnect with server and sending data again. But by this way I can get connect only 40 to 50 RTUs not all the 96. Please suggest some solution for this
pdoxtader 14-May-13 8:41am    
What operating system are you running on the server these RTUs connect to?
vinaysom 18-May-13 3:14am    
windows7 64 bit sir

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900