I'm looking for a way to detect internet connections using WinSock. In particular programs so if there is a way to determine which program each connection is associated with that would be helpful if anyone knows how to do that as well.
Printable View
I'm looking for a way to detect internet connections using WinSock. In particular programs so if there is a way to determine which program each connection is associated with that would be helpful if anyone knows how to do that as well.
... moving to the networking forum... (was in C)
Well, one way to do this would be through UDP. You'd run a UDP server on a static IP address, and you'd run the client on your computer. The client would send 5 UDP packets with a password such as 'Lightning'. (Data inside the packet)
When the server program received these packets, it would send back 5 UDP packets to the client program's IP address, with another password (such as 'Thunder'). Then, when the client received these packets, it could safely assume that there was an internet conection present.
However, this technique is not very useful considering most of us do not have a static IP server permanently connected to the internet.
Another technique would be to use ICMP to ping websites like google and Microsoft, seeing as these servers are usually up. This is quite a good technique, but ICMP is hard, or it least it is to me.
-IEatGreyFoxes
ICMP is blocked by most routers and firewalls because viruses use it to determine active IPs.
What he was asking for is which socket is associated with each program on a remote system.
You can't determine this short of running a program on the remote system that intercepts socket creation commands.
you completely didn't understand what I was talking about, I never said I wanted to determine whether or not an internet connection was present (this is actually quite simple to achieve and there are much simpler methods then listed above... such as connecting to www.google.ca on the HTTP protocol's port and if a connection is made then voila)
now what I was actually looking for is a way to locate all WinSock connections on a computer, as well as which programs these connections are associated with (if possible)
Thanks,
Tyouk
A suggestion:
go to www.sysinternals.com
download netstatp, which comes with source. It shows all locally active network connections.
what you are looking for is a port scanner, if you are talking your own computer, then you just do the same thing, connect to yourself... it is pretty simple
Also, in response to someones comment on my above post:
he is indeed looking to make a port scanner, because I will take the definition as follows from wikipedia:Quote:
I'm looking for a way to detect internet connections using WinSock. In particular programs so if there is a way to determine which program each connection is associated with that would be helpful if anyone knows how to do that as well.
"A port scanner is software designed to search a network host for open ports. This is often used by administrators to check the security of their network or by crackers to look for potential exploits on the machine."
open ports == listening programs
unless he is looking for outbound connections, in which case there is always netstat's code to look at, in other words:
google it
Yes I am indeed seeking outbound connections. Your help was great, thanks.