×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

design approach for TCP server

design approach for TCP server

design approach for TCP server

(OP)
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.  

RE: design approach for TCP server

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

RE: design approach for TCP server

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.

 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close