Re: getting client ip in sock-client on server



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,

--------------------
>From: "Ankit Aneja" <efextra@xxxxxxxxxxxxxxxxx>
>References: <uqUvfKOHGHA.2696@xxxxxxxxxxxxxxxxxxxx>
<dqntbf$179$1@xxxxxxxxxxxxxx> <Oz2fl8OHGHA.2212@xxxxxxxxxxxxxxxxxxxx>
<e0kaciPHGHA.1760@xxxxxxxxxxxxxxxxxxxx>
>Subject: Re: getting client ip in sock-client on server
>Date: Thu, 19 Jan 2006 19:18:12 +0530
>Lines: 30
>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: <OxE6AAQHGHA.3624@xxxxxxxxxxxxxxxxxxxx>
>Newsgroups: microsoft.public.dotnet.languages.csharp
>NNTP-Posting-Host: dsl-del-dynamic-067.85.246.61.touchtelindia.net
61.246.85.67
>Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
>Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.languages.csharp:379684
>X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
>
>
>No, it won't. I can't find anything in TcpClient documentation (fw 1.1)
>class that would reveal client's IP address (but I may be wrong here)
>
>can i get it using framework 2.0
>pls help
>
>
>
>
>"Goran Sliskovic" <gsliskov@xxxxxxxxx> wrote in message
>news:e0kaciPHGHA.1760@xxxxxxxxxxxxxxxxxxxxxxx
>>
>> "Ankit Aneja" <efextra@xxxxxxxxxxxxxxxxx> wrote in message
>> news:Oz2fl8OHGHA.2212@xxxxxxxxxxxxxxxxxxxxxxx
>>> will it give ip address of client
>>> i want to fetch ip address on server of client which is accepted or
>>> connected
>> ...
>>
>> No, it won't. I can't find anything in TcpClient documentation (fw 1.1)
>> class that would reveal client's IP address (but I may be wrong here) .
If
>> you can use Socket class, then you can use RemoteEndPoint property.
>>
>> Regards,
>> Goran
>>
>>
>
>
>

.



Relevant Pages

  • Re: How to tell when a socket is closed on the other end?
    ... remote server is behaving properly by closing a socket from the server side ... preferably determine if it was closed from the remote end as expected. ... All you know is that the connection did indeed get shut down. ... The SMTP user-level protocol sent "221 Bye", then, my telnet client saw the ...
    (comp.lang.python)
  • Re: SOCKET_ERROR [10054]
    ... using SocketWrench .net component. ... connection was forcibly closed by the remote host. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Tcp Sockets Close event
    ... in the old vb6 winsock object there was an Event raised when the remote side ... Closed the socket connection, ... > into the sample code to see how we handle the events generally. ...
    (microsoft.public.dotnet.academic)
  • Re: Unicast UDP Server
    ... when binding the socket. ... You're trying to bind your local socket to a remote address. ... But that would require the remote connection to be Bound to that port ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Mapping local ports to connected sockets
    ... which socket is making the connetion ... I tried enumerating all sockets and do getsockname on them, ... so even though connecthas returned, getsockname returns error. ... connection has been accepted by the other side). ...
    (microsoft.public.win32.programmer.networks)