Re: Mapping local ports to connected sockets



You can get this info at TDI layer, but this require a lot of efforts.

--
V.
This posting is provided "AS IS" with no warranties, and confers no
rights.
"Mark" <Mark@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CD768D68-7DE4-44C7-8B2C-CFE07A0865DA@xxxxxxxxxxxxxxxx
Hello,

I am adding a monitor thread to my process. The idea is to identify
which socket (as in the SOCKET identifier) is making the connetion
using which (local) port. I am doing it in a thread because
I cannot modify the original program.

I tried enumerating all sockets and do getsockname on them,
but no luck, because some of those are non-blocking connects,
so even though connect() has returned, getsockname returns error.

I'd like to be able to get that information as soon as possible,
basically once the connection has been established (I can tell
that alot of times, getsockname() fails long after the
connection has been accepted by the other side).
So I am thinking about doing it in reverse: enumerating all
connected ports and see if I can how the corresponding socket,
the question is, is that doable and how do I do that.

Thanks alot, any idea at all will help.



.



Relevant Pages

  • Re: getting client ip in sock-client on server
    ... getsockname using PInvoke mechanism. ... will give you the remote address and getsockname will give you the local ... address for the connection. ... socket handle and pass it into these API as parameters. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: INADDR_ANY
    ... But I know the real address which my server uses is ... that address is, you'll have to actually make a connection, and ... then use getsockname() on the socket to find out the socket's ...
    (comp.unix.solaris)
  • [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #3]
    ... These patches together supply secure client-side RxRPC connectivity as a Linux ... kernel socket family. ... presentation side is left to the client. ... Each connection goes to a particular "service". ...
    (Linux-Kernel)
  • [PATCH 0/5] [RFC] AF_RXRPC socket family implementation
    ... These patches together supply secure client-side RxRPC connectivity as a Linux ... Make it possible for the client socket to be used to go to more than one ... Each connection goes to a particular "service". ...
    (Linux-Kernel)
  • [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
    ... These patches together supply secure client-side RxRPC connectivity as a Linux ... Make it possible for the client socket to be used to go to more than one ... Each connection goes to a particular "service". ...
    (Linux-Kernel)