TCPSockets fails with undocumented error code

I have a server written in PureBasic, I can connect to it from a PureBasic client but when I try to connect from Xojo using a TCPSocket the connection fails and I get an error code of 49 which seems to be undocumented.

I’m using a Windows 7 64 bit PC.

Any suggestions as to what could be wrong?

error 49 in which context?

here are some windows error codes for socket, but no 49:

Hi Christian,

The code is literally as simple as this:

 myTCPSocket.Address = "" // I've tried "localhost" too
 myTCPSocket.Port = 2006

Then the myTCPSocket.Error event handler fires and myTCPSocket.LastErrorCode has a value of 49

Could it be that there’s already something connected to the port? Or that it’s expecting an SSL connection or http or something?

I’m sure none of those are the problem.

This very simple PureBasic snippet connects without a problem:

If InitNetwork() = 0
  MessageRequester("Error", "Can't initialize the network", 0)

Port = 2006
Request.s = "Hello World"

ConnectionID = OpenNetworkConnection("", Port, #PB_Network_TCP|#PB_Network_IPv4)
If ConnectionID
  MessageRequester("Info", "connected to server", 0)
  SendNetworkString(ConnectionID, Request, #PB_UTF16)
  MessageRequester("Info", "A string has been sent to the server", 0)
  MessageRequester("Error", "Failed to connect", 0)

And sure enough the server logs receiving “Hello World”.

Forget it, I’m being a numpty.

I’d created a form with a connect method which contained the code above but I was then calling the connect method of the TCPSocket directly rather than the connect method of my form so of course the TCPSocket didn’t know the address or the port I wanted it to connect to.


google is your friend