how can i develop multi client, single server chat appilcation.  
Author Message
pa.chidhambaram





PostPosted: Visual C++ General, how can i develop multi client, single server chat appilcation. Top

I have tried to create chat application in VC++ 6.0. i have placed a thread for listening client request in server program. After a single sending process. the server cannot receive the client data. i used CSocket class to create a socket. And i want to know which method, is better one. 1) Using Threads or 2) By capturing events.



Visual C++4  
 
 
einaros





PostPosted: Visual C++ General, how can i develop multi client, single server chat appilcation. Top

I have tried to create chat application in VC++ 6.0. i have placed a thread for listening client request in server program. After a single sending process. the server cannot receive the client data. i used CSocket class to create a socket. And i want to know which method, is better one. 1) Using Threads or 2) By capturing events.

Multi-threading generally introduces un-intuitive complexity you don't want to deal with unless you've got the necessary insight. You should keep the application single-threaded, and e.g. do polls on the socket to see if there's data available for reading. If there's new data; display it, otherwise keep handling GUI notifications (or send new data to the other side).

One alternative way of handling socket events without more than one thread, is to use WSAAsyncSelect (http://msdn2.microsoft.com/en-us/library/ms741540.aspx). That enables you to receive window messages e.g. when data arrives. It's generally not as efficient as overlapped IO, but granted that this application will only transport chat messages, WSAAsyncSelect should provide a good combination of speed, flexibility and ease of use.



 
 
Damien Watkins - MSFT





PostPosted: Visual C++ General, how can i develop multi client, single server chat appilcation. Top

Hello

Re: how can i develop multi client, single server chat appilcation.

Such questions (on VC++ 6.0 and general program development) are outside the scope of this forum - for the scope of the VC General forum please look at: http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=19445&SiteID=1

For such issues please use an appropriate newsgroup, potentially one at http://msdn.microsoft.com/newsgroups.

OTP

Thanks

Damien

--

PS: Einaros' information will help get your started in the right direction - thanks Einaros