S
Sandeep Singh
I am making socket client application in C#
how can i get ip address of client who has connected to server
how can i get ip address of client who has connected to server
Sandeep said:i want to get ip address on server of client which is connected
i am getting socket.LocalEndpoint but not able to get
socket.RemoteEndpoint
cl= new client(server.AcceptTcpClient());
Vitaly Zayko said:AcceptTcpClient() return a TcpClient class. It has Client property which
is a Socket. Thus you can get IPEndPoint and its IP as I mentioned in my
last message.
cl= new client(server.AcceptTcpClient());
<[email protected]> <[email protected]>
Subject: Re: get client ip address in C# socket client application
Date: Wed, 18 Jan 2006 19:09:11 +0530
Lines: 16
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Response
Message-ID: <#[email protected]>
Newsgroups: vitaly_at_zayko_dot_net,microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: dsl-del-dynamic-145.85.246.61.touchtelindia.net 61.246.85.145
Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.languages.csharp:379374
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
i am not able to get .RemoteEndpoint after cl.
in next line to accept client
cl= new client(server.AcceptTcpClient());
cl.?RemoteEndpoint is not displayed
Vitaly Zayko said:AcceptTcpClient() return a TcpClient class. It has Client property which
is a Socket. Thus you can get IPEndPoint and its IP as I mentioned in my
last message.
cl= new client(server.AcceptTcpClient());
"TerryFei" said:Hi Ankit,
In this current situation, I suggest you could try to invoke getpeername /
getsockname using PInvoke mechanism. On a connected socket, getpeername
will give you the remote address and getsockname will give you the local
address for the connection. We could use Socket.Handle Property to get the
socket handle and pass it into these API as parameters.
I hope the above inforamtion is helpful for you.If you have any questions
or concerns, please let me know. Thanks again and have a nice day!
Best Regards,
Terry Fei[MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Best Regards,
--------------------<[email protected]> <[email protected]>
<#[email protected]>
Subject: Re: get client ip address in C# socket client application
Date: Wed, 18 Jan 2006 19:09:11 +0530
Lines: 16
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Response
Message-ID: <#[email protected]>
Newsgroups: vitaly_at_zayko_dot_net,microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: dsl-del-dynamic-145.85.246.61.touchtelindia.net 61.246.85.145
Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.languages.csharp:379374
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
i am not able to get .RemoteEndpoint after cl.
in next line to accept client
cl= new client(server.AcceptTcpClient());
cl.?RemoteEndpoint is not displayed
Vitaly Zayko said:AcceptTcpClient() return a TcpClient class. It has Client property which
is a Socket. Thus you can get IPEndPoint and its IP as I mentioned in my
last message.
cl= new
client(server.AcceptTcpClient());
<[email protected]> <[email protected]>
Subject: Re: get client ip address in C# socket client application
Date: Fri, 20 Jan 2006 11:08:45 +0530
Lines: 70
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: dsl-del-dynamic-130.84.246.61.touchtelindia.net 61.246.84.130
Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.languages.csharp:379927
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
can we get remote ip address in a simple way
using framework 2.0
"TerryFei" said:Hi Ankit,
In this current situation, I suggest you could try to invoke getpeername /
getsockname using PInvoke mechanism. On a connected socket, getpeername
will give you the remote address and getsockname will give you the local
address for the connection. We could use Socket.Handle Property to get the
socket handle and pass it into these API as parameters.
I hope the above inforamtion is helpful for you.If you have any questions
or concerns, please let me know. Thanks again and have a nice day!
Best Regards,
Terry Fei[MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Best Regards,
--------------------<#[email protected]>
Subject: Re: get client ip address in C# socket client application
Date: Wed, 18 Jan 2006 19:09:11 +0530
Lines: 16
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Response
Message-ID: <#[email protected]>
Newsgroups: vitaly_at_zayko_dot_net,microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: dsl-del-dynamic-145.85.246.61.touchtelindia.net 61.246.85.145
Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.languages.csharp:379374
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
i am not able to get .RemoteEndpoint after cl.
in next line to accept client
cl= new client(server.AcceptTcpClient());
cl.?RemoteEndpoint is not displayed
"Vitaly Zayko" <vitaly_at_zayko_dot_net> wrote in message
AcceptTcpClient() return a TcpClient class. It has Client property which
is a Socket. Thus you can get IPEndPoint and its IP as I mentioned in my
last message.
cl= new
client(server.AcceptTcpClient());