CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2018
    Posts
    7

    .NET 2.0 Socket (Connection check)

    Hey guys. I created a multiple client/server application using sockets in c#. Everything works just fine. Now can you please help me create a code that will allow a client to check if another client is connected to the server(By IP)? I have an idea but I don't know how to implement it. I want something like that:

    Client #1 has connected.
    Client #2 has connected.

    Client #1 sends to server: "check 45.56.128.20"

    if client #2 is connected, do nothing. Else:

    Server sends to Client #1: "The client is not connected".

    My server size code:
    http://pastebin.com/vmwJFxFt

    My client side code:
    http://pastebin.com/YD28bNCg

    (I did not write the server&client codes)

    Thank you!

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: .NET 2.0 Socket (Connection check)

    How do you know client2 even exists?

    Asuming you have an answer to the first question, in your server code, keep a list of connected or previously connected clients. Use the list to send messages to the connected clients.

  3. #3
    Join Date
    Nov 2018
    Posts
    7

    Re: .NET 2.0 Socket (Connection check)

    Quote Originally Posted by Arjay View Post
    How do you know client2 even exists?

    Asuming you have an answer to the first question, in your server code, keep a list of connected or previously connected clients. Use the list to send messages to the connected clients.
    I already have a list in server, List Socket _clientSockets. But I don't know how to send a message to a specific IP address as I have only Socket objects.

    thank you

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: .NET 2.0 Socket (Connection check)

    Quote Originally Posted by Ornakash View Post
    I already have a list in server, List Socket _clientSockets. But I don't know how to send a message to a specific IP address as I have only Socket objects.

    thank you
    Are your storing the IP addresses in the list?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured