How do i get the Ip from a connection to my pc ?
im playing with the netmon source and id like to add the remote ip of the connection ,too.
first i need the dwRemoteAddr to close the remote connection but i cant code or read VB code.
can anyone help ?
txtOutput = ""
nRet = GetTcpTable(pTcpTable, pdwSize, bOrder)
nRet = GetTcpTable(pTcpTable, pdwSize, bOrder)
For i = 0 To pTcpTable.dwNumEntries - 1
If pTcpTable.table(i).dwState - 1 <> MIB_TCP_STATE_LISTEN Then
txtOutput = txtOutput & c_ip(pTcpTable.table(i).dwLocalAddr) & ":" & _
c_port(pTcpTable.table(i).dwLocalPort) & vbTab & _
c_ip(pTcpTable.table(i).dwRemoteAddr) & ":" & _
c_port(pTcpTable.table(i).dwRemotePort) & vbTab & _
c_state(pTcpTable.table(i).dwState - 1) & vbCrLf
Else
txtOutput = txtOutput & c_ip(pTcpTable.table(i).dwLocalAddr) & ":" & _
c_port(pTcpTable.table(i).dwLocalPort) & vbTab & _
c_ip(pTcpTable.table(i).dwRemoteAddr) & ":0" & _
vbTab & _
c_state(pTcpTable.table(i).dwState - 1) & vbCrLf
End If
Next
End Sub
VB source here [3kb netstat]: http://www.ostrosoft.com/vb/projects/iphlpapi.html
http://www.ostrosoft.com/vb/projects/iphlpapi.gif
thanks !
im playing with the netmon source and id like to add the remote ip of the connection ,too.
first i need the dwRemoteAddr to close the remote connection but i cant code or read VB code.
can anyone help ?
txtOutput = ""
nRet = GetTcpTable(pTcpTable, pdwSize, bOrder)
nRet = GetTcpTable(pTcpTable, pdwSize, bOrder)
For i = 0 To pTcpTable.dwNumEntries - 1
If pTcpTable.table(i).dwState - 1 <> MIB_TCP_STATE_LISTEN Then
txtOutput = txtOutput & c_ip(pTcpTable.table(i).dwLocalAddr) & ":" & _
c_port(pTcpTable.table(i).dwLocalPort) & vbTab & _
c_ip(pTcpTable.table(i).dwRemoteAddr) & ":" & _
c_port(pTcpTable.table(i).dwRemotePort) & vbTab & _
c_state(pTcpTable.table(i).dwState - 1) & vbCrLf
Else
txtOutput = txtOutput & c_ip(pTcpTable.table(i).dwLocalAddr) & ":" & _
c_port(pTcpTable.table(i).dwLocalPort) & vbTab & _
c_ip(pTcpTable.table(i).dwRemoteAddr) & ":0" & _
vbTab & _
c_state(pTcpTable.table(i).dwState - 1) & vbCrLf
End If
Next
End Sub
VB source here [3kb netstat]: http://www.ostrosoft.com/vb/projects/iphlpapi.html
http://www.ostrosoft.com/vb/projects/iphlpapi.gif
thanks !
I don't read VB either - and especially not VB that not indented at all ;).
You might want to look up the iphlp api in the platformsdk (or at
microsoft's online MSDN), these functions seem to be well documented.
Use GetTcpTable as a starting point.
You might want to look up the iphlp api in the platformsdk (or at
microsoft's online MSDN), these functions seem to be well documented.
Use GetTcpTable as a starting point.
Netmon uses GetTcpTable to get the list of connections, and as these list contains a MIB_TCPROW entry for each connection, you can find the remote address inside that entry:
Thomas
MIB_TCPROW STRUCT
dwState DWORD ?
dwLocalAddr DWORD ?
dwLocalPort DWORD ?
[b] dwRemoteAddr DWORD ?[/b]
dwRemotePort DWORD ?
MIB_TCPROW ENDS
Thomas
....You might want to look up the iphlp api in the platformsdk (or at microsoft's online MSDN), these functions seem to be well documented....Use GetTcpTable as a starting point.
I recently posted the docs & include for iphlpapi in the networking section.
Thomas
searching hours google and then the result is since weeks on my pc *hahaha*
thanks thomas !
thanks thomas !