I have the DWORD socket in windows. I need to know if it is a connection that goes out to the internet or if it is a local connection, to some form of localhost. Is there a good way to get the address that the socket is connected to in windows from just the socket? Or is there a better way to tell if the connection is local or not?
+3
A:
You probably want to call getpeername()
. Using it is pretty basic, you pass a sockaddr
pointer and a length and it fills in the data for you.
As far as determining if the connection is local, getaddrinfo()
can give you a list of all available local addresses. You would compare the result of getpeername()
to the local address list.
Clay
2009-07-15 02:18:40