0

I was looking for some advice on the best approach to a TCP/IP based server. I have done quite a bit of looking on here and other sites and cant help think what I have saw is overkill for the purpose I need it for.

I have previously written one on a thread per connection basis which I now know wont scale well, but what I was thinking was rather that creating a new thread per connection I could use a ThreadPool and queue the incoming connections for processing as time isn't a massive issue (provided they will be processed in less that a minute or two of coming in).

The server itself will be used essentially for obtaining data from devices and will only occasionally have to send a response to the sending device to update settings (Again not really time critical as the devices are setup to stay connected for as long as they can and if for some reason if it becomes disconnected the response will be able to wait until the next time it sends a message).

What I wanted to know is will this scale better than the thread per connection scenario (I assume that it will due to the thread reuse) and roughly what kind of number of devices could this kind of setup support.

Also if this isn't deemed suitable could someone possibly provide a link or explanation of the SocketAsyncEventArgs method. I have done quite a bit of reading on the topic and seen examples but cant quite get my head around the order of events etc and why certain methods are called at the time the are.

Thanks for any and all help.

I have read the comments but could anybody elaborate on these? Though to be honest i would prefer the initial approach of of rolling my own.

  • And why not use a powerful, tested and configurable framework? Like WPF or Nancy? – H H Jan 12 '14 at 11:33
  • Could you point me to some links? – JohnyHarkness Jan 12 '14 at 12:26
  • Use the async methods. You'll improve your scalability immensely & they're not that difficult once you understand the pattern. – Simon Halsey Jan 12 '14 at 13:09
  • Do you know of any good sources? If have read quite a few tutorials but none seem to explain the basics of how, why and when particular events / method are being executes – JohnyHarkness Jan 12 '14 at 13:11
  • @HenkHolterman WPF & Nancy aren't really network frameworks. They're more UI frameworks. I'd agree with what you've said though - use a tested, mature framework. perhaps something like WCF, Mass Transit, etc – Simon Halsey Jan 12 '14 at 13:11
  • @SimonHalsey - Yes, WPF was a typo, i did mean WCF. I'm not sure how usable Nancy is outside HTTP but it was just about the genral idea. Application developpers should very rarely use sockets. – H H Jan 12 '14 at 18:02

0 Answers0