How to know whether there are connected clients while using Socket Programming?
-
Hey buddies ........ I just started to make local area chat ............ I can send and recieve stream of data but how do i know whether the connected client(s) are disconnected or not while chatting? One other thing I want to ask is ................. How can I send Images with each other in this clients ..... and to display one image from one client to another clients picture box? ................ I appreciate your help. Thank you.
-
Hey buddies ........ I just started to make local area chat ............ I can send and recieve stream of data but how do i know whether the connected client(s) are disconnected or not while chatting? One other thing I want to ask is ................. How can I send Images with each other in this clients ..... and to display one image from one client to another clients picture box? ................ I appreciate your help. Thank you.
-
Hey buddies ........ I just started to make local area chat ............ I can send and recieve stream of data but how do i know whether the connected client(s) are disconnected or not while chatting? One other thing I want to ask is ................. How can I send Images with each other in this clients ..... and to display one image from one client to another clients picture box? ................ I appreciate your help. Thank you.
-
If they disconnect, the socket dies. Sending an image is the same as sending text really, but if you previously only sent text you'll need a way to keep text and images apart (just stick an int in front of them or something like that)
Thank you for your help .....
harold aptroot wrote:
If they disconnect, the socket dies.
so .... is there a method or something to know which socket dies(i mean which user disconnected)? I think it looks silly question. Thank you agian
-
Hi, use a static integer variable to count the active clients in your main thread of server. ;-) each time a client connects count 1 up. and decrease if the clients disconnects. bye
Yes, I thought in that way but .... I want to know when they are disconnected ... my question really here.... How do I know when one client is disconneted. Thank you man.
-
Thank you for your help .....
harold aptroot wrote:
If they disconnect, the socket dies.
so .... is there a method or something to know which socket dies(i mean which user disconnected)? I think it looks silly question. Thank you agian
-
Of course, when you're trying to use a socket and it throws an exception, then that's the socket which died
ok .... i will try that