|
-
Jan 4th, 2006, 10:46 PM
#1
Thread Starter
Addicted Member
[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.
-
Jan 5th, 2006, 01:04 AM
#2
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:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_HIDE As Long = 0
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Const SW_SHOWMINIMIZED As Long = 2
Private Sub Command1_Click()
'If running XP then you can use the -ano switch.
'Also, if not running XP then the path to CMD.exe will be different. This can be dynamically obtained
'by using the GetSystemDirectory API
ShellExecute Me.hWnd, "Open", "C:\Windows\System32\CMD.exe", " netstat -ano >C:\Ports.tmp", "C:\", SW_HIDE
'If running pre-XP then just -ao
'ShellExecute Me.hWnd, "Open", "C:\Windows\System32\CMD.exe", " netstat -ao >C:\Ports.tmp", "C:\", SW_HIDE
'ToDo: After process is completed, read the file back in.
'...
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jan 22nd, 2006, 11:42 AM
#3
Member
Re: Listing IP of PCs connected to me...
how about this
VB Code:
Private Sub socket_ConnectionRequest(Index As Integer, ByVal requestID As Long)
Load Socket(Socket.UBound + 1)
Socket(Socket.UBound).Accept requestID
[COLOR=darkred]List1.AddItem "Connection request id " & requestID & " from " & [b]Socket(Index).RemoteHostIP[/b][/COLOR][b] [/B]
End Sub
or
VB Code:
Private Sub ListIPs
For i = Socket.LBound to Socket.UBound
if socket(i).state = 7 then [COLOR=darkred]List1.AddItem "Connection " & i & [b]Socket(Index).RemoteHostIP[/b][/COLOR][b] [/B]
next i
End Sub
Last edited by dlern; Jan 22nd, 2006 at 11:56 AM.
-
Jan 22nd, 2006, 07:36 PM
#4
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|