EDIT I accidentaly found a walk around to this problem… Adding the following line in the begining of the function solved the problem for some reason…
remoteIPAdress = remoteIPAdress & "END"
Hello.
I have a school assignment where I am supposed to build a simple TCP/IP messenger in Visual Basic…
The problem is that when the client sends his IP in a request I’ve built (“LetMeIn\XXX.XXX.XXX.XXX”), even if the server receives the request as it should, it parses it completely wrong…
To be more exact, when I run this snippet I get these results:
Private Function findFreeIPEndPoint(ByVal remoteIPAdress As String) As IPEndPoint
Dim ipEndPoint As IPEndPoint
System.Diagnostics.Debug.Write("LOL! The IP adress you try to parse is " & remoteIPAdress)
System.Diagnostics.Debug.WriteLine("The parsed result is " & String.Concat(IPAddress.Parse(remoteIPAdress)))
ipEndPoint = New IPEndPoint(IPAddress.Parse(remoteIPAdress), 1003 + topUniqueId)
MessageBox.Show(String.Concat(ipEndPoint.Address))
System.Diagnostics.Debug.Write("The IP adress you got is " & String.Concat(ipEndPoint.Address))
Try
listener(ipEndPoint.Port - 1003).Start()
Catch ex As Exception
End Try
topUniqueId = topUniqueId + 1
Return ipEndPoint
End Function
Output:
LOL! The IP adress you try to parse is 192.168.1.65
A first chance exception of type ‘System.FormatException’ occurred in System.dll
If i change the following line
ipEndPoint = New IPEndPoint(IPAddress.Parse(remoteIPAdress), 1003 + topUniqueId)
to
ipEndPoint = New IPEndPoint("192.168.1.65", 1003 + topUniqueId)
I get this:
The IP adress you got is 229.64.116.11
Weird right?
Edit:
With the edited question, my guess is that the input is not
"192.168.1.65“, but actually contains padding. Perhaps as simple as"192.168.1.65 ". Check the string carefully. Heck, check the.Lengthfirst, then character by character.Original answer based on the original question
I don’t believe the output you are displaying is true, in part because of the missing LOL! But also, you have one of the numbers hard-coded; surely it should be:
Also keep in mind the differnce between a local IP and a public IP. A 192.168 IP is your LAN. Remote clients won’t have that, but will be using a public IP address translated via their router/proxy/whatever.