Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Coder's Corner Lounge (http://www.programmingforums.org/forum11.html)
-   -   server - messenger chat... (http://www.programmingforums.org/showthread.php?t=13588)

programmingnoob Jul 18th, 2007 11:14 PM

server - messenger chat...
 
I am coding a centralized server messenger...

I wonder what approach do Yahoo, AIM etc use for text chat?

Suppose two clients start chatting with each other, now during the chat conversation, does every single message during the conversation go through the server and the server redirects it to the proper client? OR does the server redirects the first message and then the two clients start communicating directly ie their messages get transmitted to each other directly, not going through the server?

did I make my question clear?

DaWei Jul 18th, 2007 11:55 PM

I would suggest that you research the UDP protocol, the client/server paradigm, and the methods for getting around that. It isn't pretty, if you care about security.

programmingnoob Jul 19th, 2007 12:06 AM

Quote:

Originally Posted by DaWei (Post 130860)
I would suggest that you research the UDP protocol, the client/server paradigm, and the methods for getting around that. It isn't pretty, if you care about security.

I am using TCP, not UDP...

just wanted to know about AIM, Yahoo etc...

do you know whether they let the clients communicate directly after a point or does every single message go through the server at any point of the conversation?

Jimbo Jul 19th, 2007 12:28 AM

I'm pretty sure MSN and AIM have a separate feature for directly connecting to the other person. Otherwise, I'm pretty sure it goes through the server; for instance, with AIM you can be logged on in several locations (MSN has something similar in the works I think), and they'll all receive the messages. I've not tried being logged in several times and using a direct connection. And no idea how Yahoo or Jabber or other protocols behave, as I don't use them.

DaWei Jul 19th, 2007 12:48 AM

Any time one 'client' can receive from another 'client', and respond, your system has been compromised. That's at the user's discretion, of course. The user has allowed software to be downloaded that compromises security. If the downloaded compromise has not (yet) been hacked, you will be extremely lucky. Most users in this position that have not been stolen blind have escaped solely because they have been judged as having no information on their system that is worthwhile, relatively speaking.

glimmy Jul 19th, 2007 1:04 AM

Concerning Jabber, it uses servers for communication, but there is no single main server like AIM or MSN. (see RFC 3920 Section 2 briefly describes clients, servers, etc. within Jabber)

Otherwise, unless you are doing this for educational reasons, it would be more secure and probably easier to implement if you used an existing protocol like XMPP (Jabber) or perhaps build off of IRC.

Duck Jul 19th, 2007 7:36 AM

Quote:

Originally Posted by programmingnoob (Post 130859)
I am coding a centralized server messenger...

I wonder what approach do Yahoo, AIM etc use for text chat?

Suppose two clients start chatting with each other, now during the chat conversation, does every single message during the conversation go through the server and the server redirects it to the proper client? OR does the server redirects the first message and then the two clients start communicating directly ie their messages get transmitted to each other directly, not going through the server?

did I make my question clear?

The easiest approach is for every message to go through the server, Client->Server->Client.

Otherwise as you say, if client_1 wanted to communicate with client_2, client_1 could retrieve, from the server, the IP address of client_2, and then connect directly to client_2. This would be a 'peer to peer' connection.

As a n00b programmer you should not attempt to write a p2p application. It is not easy to create a p2p connection, there are a lot of problems involved. For example most most PCs connect to the internet from behind a router, when a connection is made through the router a NAT (network address translator) is implemented to convert private network addresses in an internal network (LAN) into one public address for the internet. But the NAT only works one way, a PC on a LAN can initiate a connection through the NAT (router) to a 'server' on the internet. But a 'server' on the internet cannot initiate a connection through a NAT to a PC on a LAN, because the NAT (router) would not know which PC on the LAN to direct the connection to.

There is a way round this problem, they call it 'hole punching technology' where each peer creates and listens for a connection at the same time on the same port. Blah Blah blah, read up on p2p and NAT.

I think MSN messenger does try and establish a p2p connection, but if it fails all traffic goes through a server (EDIT: but the other way around - a reliable C->S->C connection is 1st established then p2p is attempted). p2p connections can't always be established.


All times are GMT -5. The time now is 2:27 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC