Detecting WinSock Connections

This is a discussion on Detecting WinSock Connections within the Networking/Device Communication forums, part of the General Programming Boards category; I'm looking for a way to detect internet connections using WinSock. In particular programs so if there is a way ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    132

    Detecting WinSock Connections

    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.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    ... moving to the networking forum... (was in C)
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    8
    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

  4. #4
    Registered User
    Join Date
    Jul 2004
    Posts
    9
    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.

  5. #5
    Registered User
    Join Date
    May 2002
    Posts
    132
    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

  6. #6
    .
    Join Date
    Nov 2003
    Posts
    307
    A suggestion:

    go to www.sysinternals.com

    download netstatp, which comes with source. It shows all locally active network connections.

  7. #7
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790
    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
    there used to be something here, but not anymore

  8. #8
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790
    Also, in response to someones comment on my above post:

    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.
    he is indeed looking to make a port scanner, because I will take the definition as follows from wikipedia:

    "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
    Last edited by EvBladeRunnervE; 07-15-2004 at 10:24 AM.
    there used to be something here, but not anymore

  9. #9
    Registered User
    Join Date
    May 2002
    Posts
    132
    Yes I am indeed seeking outbound connections. Your help was great, thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Winsock issues
    By tjpanda in forum Windows Programming
    Replies: 3
    Last Post: 12-04-2008, 08:32 AM
  2. Detecting Connections
    By jmd15 in forum Networking/Device Communication
    Replies: 2
    Last Post: 06-16-2006, 11:12 AM
  3. Where do I initialize Winsock and catch messages for it?
    By Lithorien in forum Windows Programming
    Replies: 10
    Last Post: 12-30-2004, 12:11 PM
  4. Winsock Problem
    By Noxir in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2004, 11:50 AM
  5. winsock
    By pode in forum Networking/Device Communication
    Replies: 2
    Last Post: 09-26-2003, 01:45 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21