none
How to check if same client is reconnected in client socket RRS feed

  • Question

  • Hi, I make a client-server application using wpf. In server application, all connected client is added to listbox and all client has a countdown timer and online-offline icon in that list. Server app is to monitor the online-offline and time left of the client app, when the clinet has timed out then in server will show a messagebox/notification that this client has timed out. I can detect online-offline client, but, how to detect if same client is reconnected (disconnected before the client is timed out). For example, when a problem in network connection, and the client is temporary disconnected then the icon of this client in the client listbox is changed to offline and when the network is back online then the client reconnect automatically to server and synchronize the countdown timer in client and server and client's icon is changed to online?

    Thank you,

    Saturday, January 7, 2017 12:27 PM

Answers

  • Hi ichigo56,

    Thank you for feedback.

    When the Socket connect to clients, it has two pasts information, IP and port. You compare IP first to make sure whether it is the same client. And then use the Socket.RemoteEndPoint Property to get the port and compare it.

    I hope this would be helpful to you.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by ichigo56 Wednesday, January 11, 2017 4:15 PM
    Tuesday, January 10, 2017 8:14 AM
    Moderator

All replies

  • Have the clients send an identifier to the server, so that when they reconnect you know it's the same client.

    In HTTP this problem is addressed by having the server send a Session Identifier to the client, which the client then sends with every request.  This way a Session can span TCP/IP connections.

    David


    Microsoft Technology Center - Dallas

    My Blog


    Saturday, January 7, 2017 12:52 PM
  • Hi ichigo56,

    Thank you for posting here.

    For your question, as I know, you could check it via port.

    When the client connected to the Socket, please record the port. When the client disconnected and try to connect to the Socket, it will connect with another port. 

    You could compare the port to check if the same client reconnected in client Socket.

    I hope this would be helpful.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, January 10, 2017 5:40 AM
    Moderator
  • Thank you for all the replies,

    @David yes, I give a computer number on every client and save it in app.config. And the user will set it manually when run the application at first time.

    @Wendy So, when the client is reconnected then we compare the port?


    • Edited by ichigo56 Tuesday, January 10, 2017 6:30 AM
    Tuesday, January 10, 2017 6:29 AM
  • Hi ichigo56,

    Thank you for feedback.

    When the Socket connect to clients, it has two pasts information, IP and port. You compare IP first to make sure whether it is the same client. And then use the Socket.RemoteEndPoint Property to get the port and compare it.

    I hope this would be helpful to you.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by ichigo56 Wednesday, January 11, 2017 4:15 PM
    Tuesday, January 10, 2017 8:14 AM
    Moderator
  • I have solve it now. What I did is create id on every client and when client connected to server, then the server give a unique id to client (like a session) then when the client is disconnected and reconnect again, it sends client id and session id to server and the server compare this id's and I combine it with checking the ip and port too.

    Thank you for the help

    Wednesday, January 11, 2017 4:15 PM