Jump to content
Dion

Winsock not listening

Recommended Posts

I've just converted a smallish VB6 winsock server program to VB 2017.  It's successfully converted to AxMSWinsockLib, and after the usual minor changes to code (non associated with winsock), it compiles and runs, but winsock events don't seem to trigger. Netstat shows that the port is listening and I can see attempted connections from the client (which is still VB6).

The sub definition lines (as created by mobilze) are:

Private Sub Socket_ConnectionRequest(ByVal eventSender As Object, ByVal eventArgs As AxMSWinsockLib.DMSWinsockControlEvents_ConnectionRequestEvent) Handles _Socket_0.ConnectionRequest

Private Sub Socket_DataArrival(ByVal eventSender As Object, ByVal eventArgs As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles _Socket_0.DataArrival

Private Sub Socket_CloseEvent(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles _Socket_0.CloseEvent
 

Anyone had similar issues? Is there something obvious I'm missing? Any other ideas? Do I just rewrite to System.Net.Sockets?

Share this post


Link to post
Share on other sites

Hello Dion,

Do you have a firewall that may be blocking connections attempts? You can try by implementing the winsock error event to trap error messages.

My suggestion given you're now in .Net, replace the winsock by System.Net.Sockets. The communication between .Net and Interop/Activex components my be not as smoothly as expected, so using a pure .Net component could be the best option.

Some guides about .Net sockets:

https://docs.microsoft.com/en-us/dotnet/framework/network-programming/synchronous-client-socket-example 

https://docs.microsoft.com/en-us/dotnet/framework/network-programming/synchronous-server-socket-example

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Terms of Use