Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

design approach for TCP server

Status
Not open for further replies.

MiMoore

Programmer
Aug 25, 2005
12
0
0
IE
Hello,

I had posted this in data transmission section - but it was recommended to post in programming section.


I'm in the process of reading up on tcp.
i hav a project working in unix/C programming environment and I want to design a multi client tcp server.
Basically I would like to know if there is existing design pattern in C/unix domain.
Here is some more information on the problem.
Since I'm new to all this, really I would like your advice and input as to what I should consider for scalable efficient solution.
The server would need to support multiple connections from clients applications ( maybe a couple 100 of apps)
The clients could be http and other type applications.
Considering that different applications needs to be supported should I consider using multiple TCP listening ports? Would this be useful afterwards when determining where the data should be forwarded to to handle further app specific processing (example receive data on tcp socket X so so route to another local app for http data processing)
Or could I have just one socket and let all the connections and data through this single socket? With this approach, would the server need advanced intelligence to determine that type of data received from the different client apps?
What is the best way to correlate data from socket from HTTP client app to a local http handler.

What is the most efficient way to read data from socket. Maybe I could use timer based approach or I have also seen software interrupt SIGIO where a signal handler could be provided.

Should I consider some multi threading for the server to handle each connection or forking.

Any thoughts/inputs on any design patterns alrready out there and/or best approach would be appreciated.

thanks.
 
hi,
approach the problem in inductive manner: make going
it on a port, and an adress, a protocol, then complicate it.

I believe that the multyThread / socket (Synchronous or Asynchronous ? ) is the best solution: is more difficult to start, but you have not to synchronize the different calls from different clients.

But all depends, not from C language, but from the environment in which you deploy the project and you run it.
If you run in Unix environment, free tools, or Microsoft Windows Studio (MFC or not), the solution may be different.
I suggest to use some of them (you have also to manage multyThread) instead use a basic C compiler with the base socket() routine.

bye
victor
 
It's easier to do a socket listener that does a fork() and exec() to handle the incoming connection. Plus, since you want this to do all kinds of different things, you just need to exec() something different to handle whatever the incoming request needs. Plus there are plenty of examples available on the Internet and in books.

At least that's how I would start.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top