-
November 18th, 2018, 07:57 PM
#1
.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!
-
November 18th, 2018, 10:54 PM
#2
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.
-
November 19th, 2018, 03:26 AM
#3
Re: .NET 2.0 Socket (Connection check)
Originally Posted by Arjay
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
-
November 19th, 2018, 02:12 PM
#4
Re: .NET 2.0 Socket (Connection check)
Originally Posted by Ornakash
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|