Search code examples
vb6winsock

Listen() function for Winsock


I am using VB6, and I want to create a chat application that works on a LAN. I used the WinSock control, but when I run the Listen() function my socket just listens on 127.0.0.1 and not my computer's IP on the LAN.

Why? Is there any way to listen on my IP on the LAN?


Solution

  • Normally you would call the Bind method to set the local port and optionally specify the local IP address of the adapter to use. It should default to your system's primary adapter. Then you call Listen with no arguments after that.

    You can skip Bind and just set LocalPort then Listen but it isn't advisable except in simple single-connection server scenarios.

    None of that explains why your loopback address is being selected by default though. Sounds like some sort of network configuration problem on the box.