views:

51

answers:

1

Hi i am writing a socket client/server application in VB6. i have the following code

Private Sub sockMain_ConnectionRequest(ByVal requestID As Long)
    If sockMain.State <> sckClosed Then
        sockMain.Close
    End If
    sockMain.Accept requestID    
    Debug.Print "Accepted connection from: " & sockMain.RemoteHostIP & vbCrLf
End Sub

its printing the IP but the last digit is missing example, if my connection is from "192.168.1.123" then it shows "192.168.1.12" only

A: 

I've tried the exact same code and it works on my machine. I tried using telnet from the same machine, and also from a laptop and the correct IP address was printed in both cases.

I have to agree with ckv and say that its the way you are printing RemoteHostIP.

quamrana
If you used exact same code you must have used same function to print the IP also right? So you mean with same code as Dharma has mentioned above you are getting correct IP.
ckv
Yep, I just pasted the code from the OP into my form.
quamrana
Hi CKV and quamrana, still i am not getting why in my system the last digit is missing. even if i set a watch for the socket object and checked during debug, still shows the RemoteHostIP by truncating the last character.
Dharma
@Dharma: OK, that's bad. Can you try a minimal version of the program on some different hardware/OS?
quamrana
Except vb6 winsock control, other programming languages line VC++, C# and VB.Net i am able to get the RemoteIP address complete.
Dharma
@Dharma: So what hardware/OS *are* you using to get the symptoms you describe in your question?
quamrana
Pentium(R)D CPU 2.8 GHz/Windows XP sp2
Dharma
@Dharma: Any chance of trying it on Vista or Windows 7? btw My machine is Windows XP SP3.
quamrana
Currently i am tied with other schedules..i will check this later,may be this week end.
Dharma