Results 1 to 4 of 4

Thread: [RESOLVED] Listing IP of PCs connected to me...

  1. #1

    Thread Starter
    Addicted Member bulletrick's Avatar
    Join Date
    Jul 2005
    Location
    Philippines
    Posts
    248

    Resolved [RESOLVED] Listing IP of PCs connected to me...

    Hello. I already have winsock server and client programs. i have one server and about 10 clients.

    How do I list all the IP addresses of computers connected to the server? Can I also do this in the clients?
    Last edited by bulletrick; Jan 4th, 2006 at 10:50 PM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Listing IP of PCs connected to me...

    One way would be to shell out the netstat dos command and output its results to a textfile. Then read it back in to your app.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, _
    4. ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    5.  
    6. Private Const SW_HIDE As Long = 0
    7. Private Const SW_SHOWNORMAL As Long = 1
    8. Private Const SW_SHOWMAXIMIZED As Long = 3
    9. Private Const SW_SHOWMINIMIZED As Long = 2
    10.  
    11. Private Sub Command1_Click()
    12.     'If running XP then you can use the -ano switch.
    13.     'Also, if not running XP then the path to CMD.exe will be different. This can be dynamically obtained
    14.     'by using the GetSystemDirectory API
    15.     ShellExecute Me.hWnd, "Open", "C:\Windows\System32\CMD.exe", " netstat -ano >C:\Ports.tmp", "C:\", SW_HIDE
    16.     'If running pre-XP then just -ao
    17.     'ShellExecute Me.hWnd, "Open", "C:\Windows\System32\CMD.exe", " netstat -ao >C:\Ports.tmp", "C:\", SW_HIDE
    18.     'ToDo: After process is completed, read the file back in.
    19.     '...
    20. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Member
    Join Date
    Jan 2006
    Posts
    40

    Re: Listing IP of PCs connected to me...

    how about this
    VB Code:
    1. Private Sub socket_ConnectionRequest(Index As Integer, ByVal requestID As Long)
    2.  
    3.   Load Socket(Socket.UBound + 1)
    4.   Socket(Socket.UBound).Accept requestID
    5.   [COLOR=darkred]List1.AddItem "Connection request id " & requestID & " from " & [b]Socket(Index).RemoteHostIP[/b][/COLOR][b] [/B]
    6. End Sub
    or
    VB Code:
    1. Private Sub ListIPs
    2. For i = Socket.LBound to Socket.UBound
    3.    if socket(i).state = 7 then [COLOR=darkred]List1.AddItem "Connection  " & i & [b]Socket(Index).RemoteHostIP[/b][/COLOR][b] [/B]
    4. next i
    5. End Sub
    Last edited by dlern; Jan 22nd, 2006 at 11:56 AM.

  4. #4

    Thread Starter
    Addicted Member bulletrick's Avatar
    Join Date
    Jul 2005
    Location
    Philippines
    Posts
    248

    Question Re: Listing IP of PCs connected to me...

    Thanks dlern and RobDog888!

    RobDog888, I am concerned with my classmates. I don't think they will understand what you gave me. Hehe. But it's good! Thanks!

    dlern, this is better because it is more straightforward.

    Thanks everyone!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width