0

I am relatively new to server programming, but I read some useful tutorial. I have this question:

What is the best way to handle multiple clients?

I read that there are several solutions, but i do not know if some of them are too complex for my application. I have to use C code (since I already have the libraries) on a micro-controller and I need a web server to periodically monitor some data received by some sensors (temperature and humidity from each sensor). I may also want to send some data to clients. Some sample code and links that help me read about this would be very helpful. Thank you

  • see: http://stackoverflow.com/questions/5290860/trying-to-implement-concurrent-tcp-server-and-client-in-c – ninjalj Jul 23 '12 at 17:31

1 Answers1

0

If the web server is Microsoft IIS, you can use ISAPI/CGI/FastCGI. Basically you have to write a DLL (in native code, eg C) containing functions called for each user request, and generate an output. I think this is the most suitable way, as those libraries (for the micro-controller and the sensors) are in C as well, as you have mentioned.

And a note, in order to prevent crashes IIS uses process isolation (if I remember the term exactly), which means that the DLL is called in the context of a different process for each request, not as threads. This may not be very good in terms of performance/resource management, eg if you want the libraries connecting to the HW only once (during initialization). Not sure if a mechanism to create threads (rather than separate processes) is provided, so pls check the documentation. Otherwise you can make another DLL and connect to it via interprocess communication techniques (eg pipes), but this is extra work of course.

Hope this helps.

Constantine Georgiou
  • 2,412
  • 1
  • 13
  • 17