Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to know whether there are connected clients while using Socket Programming?

How to know whether there are connected clients while using Socket Programming?

Scheduled Pinned Locked Moved C#
questionhelptutoriallounge
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CoderForEver
    wrote on last edited by
    #1

    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.

    L M 2 Replies Last reply
    0
    • C CoderForEver

      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.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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)

      C 1 Reply Last reply
      0
      • C CoderForEver

        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.

        M Offline
        M Offline
        monstale
        wrote on last edited by
        #3

        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

        C 1 Reply Last reply
        0
        • L Lost User

          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)

          C Offline
          C Offline
          CoderForEver
          wrote on last edited by
          #4

          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

          L 1 Reply Last reply
          0
          • M monstale

            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

            C Offline
            C Offline
            CoderForEver
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • C CoderForEver

              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

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Of course, when you're trying to use a socket and it throws an exception, then that's the socket which died

              C 1 Reply Last reply
              0
              • L Lost User

                Of course, when you're trying to use a socket and it throws an exception, then that's the socket which died

                C Offline
                C Offline
                CoderForEver
                wrote on last edited by
                #7

                ok .... i will try that

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups