Click here to Skip to main content
16,004,406 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm stuck with this problem and I don't know how to solve it.

I have made a client/server application and I want to make multi-clients connect to the server via the Lan network.
I distinguishes between each client using IP's.

My problem is how can I retrieve ip addresses for each client and put them as strings inside textbox?
Posted
Updated 17-May-11 23:08pm
v2
Comments
Dalek Dave 18-May-11 5:09am    
Edited for Grammar, Spelling, Syntax and Readability.

When you already have the connection in your program.
It is not hard go get the remote endpoint IP address.

Check out TcpClient.Client.RemoteEndPoint under TcpClient [^] that has been created when you called AcceptTcpClient.

C#
string endPoint = tcpClient.Client.RemoteEndPoint.ToString();
Console.WriteLine("Remote endpoint is: " + endPoint);
 
Share this answer
 
v2
Comments
hamzah1 18-May-11 5:05am    
iam using socket's ,but can you give me more detail about RemoteEndPoint please ?iam new in this stuff
Kim Togo 18-May-11 5:08am    
Do a .ToString() on the RemoteEndPoint.
Without knowing more it is difficult to say, but if you are using Sockets it's no problem. If you use TCPClient then get the socket via the TCPClient.Socket property first.

Then all you need is the Socket.RemoteEndPoint[^] property. A quick ToString, and it's ready for your textbox!
 
Share this answer
 
Comments
hamzah1 18-May-11 5:04am    
iam using socket's ,but can you give me more detail about RemoteEndPoint please ?iam new in this stuff
OriginalGriff 18-May-11 5:08am    
Um. Click the link?
hamzah1 18-May-11 5:20am    
sry :D
OriginalGriff 18-May-11 5:24am    
No problem! :laugh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900