PDA

Click to See Complete Forum and Search --> : Capturing data in Socket Programming


stems
May 8th, 2006, 10:09 AM
I am testing a cleint/server system writen in VB.Net 2005 using asynchronous connections and I discovered that with Net 2.0 I can use the Config.exe.ini file to capture data. The data captured includes detailed information but I cannot find a way to discover the client IP. A sample of the data is as follows:-

System.Net.Sockets Verbose: 0 : [0740] Socket#30015890::BeginAccept()
System.Net.Sockets Verbose: 0 : [0740] Exiting Socket#30015890::BeginAccept() -> AcceptAsyncResult#1707556

Can anybody advise whether the Socket# can somehow lead me to the details of the Client connection, ex IP/Port.

Thanks

MagellanTX
May 25th, 2006, 03:45 PM
I don't know how that config file stores its ports but the IP address is in long format. I'm sure there are simpler ways of breaking this down but I just do the math to reverse it back to IP address.

Dim LongIPAddress As Long = 30015890

Dim num As Integer
Dim sIP(4) As String

For i As Integer = 1 To 4

num = Int(LongIPAddress / 256 ^ (4 - i))
LongIPAddress = LongIPAddress - (num * 256 ^ (4 - i))


sIP(4 - i) = num & "."

Next

Dim IPAddress As String = String.Concat(sIP)
IPAddress = IPAddress.TrimEnd(".")

HTH