Click to See Complete Forum and Search --> : IM Server


HeWhoIs
March 25th, 2008, 08:51 PM
I'm currently working on an IM program, and just am just starting work on the program's server. I don't really have much experience with network programming, and had a couple of questions.

First of all, is it practical to run a separate thread for each user? In not, is there really any alternative? (I'm using TCP.) If it matters, it's a P2P server, so it just performs various utilities. The actual individual messages are sent via direct connections between users.

Which brings me to my other question: It's my understanding that a connection is defined by *both* endpoints, not just one. That is, two separate connections on a single port will not interfere with each other. (Assuming that the opposite endpoints are unique) Is this true?

dglienna
March 25th, 2008, 09:35 PM
That would be ONE-TIER.

Look up TWO-TIER. All modern IM's connect to a SERVER (1) and from there, the server connects to another client (2)

The server just serves clients in order

HeWhoIs
March 26th, 2008, 02:32 AM
Could you elaborate a little? I looked up the terms (one- and two-tier) as I'm not familiar with them, and the only definitions I could find didn't really seem relevant. They had to do with where processing of data takes place, and I'm not sure I see the connection.

"The server just serves clients in order."

And there's the problem. There's no way I know of, (in C#, at least, which is what I'm using) to handle messages from multiple clients in the order they arrive other than to have the clients establish a separate connection for each message. Unfortunately, in an this situation, it's rather important to keep the connection open throughout the session to ensure proper notification if a connection is abruptly lost. (The overhead of not only creating a new connection for each message but also consistently creating new connections to ping users is simply unacceptable.)

But, more importantly, I'd really prefer to know the answers to the questions before
I start exploring the alternatives.