0

I have implemented TCp concurrent server and client in c using threads as well as forks. But I don't have any way to check whether there is any other standard way of implementing this.

I have goggled for standard coding stuff but didnt find anything useful. Can someone pl z share some good links or code so that I can have a standard idea of implementing Concurrent servers.

Thanks for help

Sandeep Pathak
  • 10,567
  • 8
  • 45
  • 57
  • What do you mean by "Concurrent server"? Handling more than one client connection? – Brian Roach Mar 13 '11 at 16:59
  • I answered something similar a few days ago - http://stackoverflow.com/questions/5267535/how-does-an-asynchronous-socket-server-work – Erik Mar 13 '11 at 16:59
  • @Brian : yeah the same...Also Full duplex communication between Client and Server........... – Sandeep Pathak Mar 13 '11 at 17:03
  • See also this answer to a question about event-driven webservers: http://stackoverflow.com/questions/3981566/what-is-event-driven-web-server/3982440#3982440 – ninjalj Mar 13 '11 at 20:35

3 Answers3

3

There's no "standard idea". Your approach is going to depend on requirements, performance, scalability, and amount of time allowed for development.

  • One thread per client
    • Possibly with a threadpool
  • Multi-threaded pipeline model, with N workers
  • One thread per server, using poll/select
  • One thread per server, event-based with callbacks
  • Forking children, one per client connection
    • pre-forking children, e.g. Apache web server

Etc. All of these have their uses.

Brian Roach
  • 76,169
  • 12
  • 136
  • 161
2

Some good links for you:

Hope this helps.

Nikolai Fetissov
  • 82,306
  • 11
  • 110
  • 171
1

Concurrent servers (as long as they are quite simple, and performance is not much of an issue) are often created with poll() or select(). Now, this is assuming you are on *nix. If you can use C++, the boost libraries have ASIO , which is a cross-platform library that allows you to write once and compile everywhere. There isn't really a standard way to do things since the ideas vary from OS to OS.

Dhaivat Pandya
  • 6,499
  • 4
  • 29
  • 43