From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

SocketCore.Error(e As RuntimeException)

Supported for all project types and targets.

Occurs when an error occurs with the socket.


These error codes provide you with key information about your socket, and it is not advisable to ignore them.

When an error occurs, the RuntimeException.ErrorNumber property will likely contain one of the following error codes:

Error Code Description
0 No error occurred.
100 There was an error opening and initializing the drivers.

It may mean that WinSock (on Windows) is not installed, or the version is too early.

101 This error code is no longer used.
102 This code means that you lost your connection.

You will get this error if the remote side disconnects (whether its forcibly- by pulling their ethernet cable out of the computer), or gracefully (by calling SocketCore's Close method). This may or not be a true error situation. If the remote side closed the connection, then it is not truly an error; it's just a status indication. But if they pulled the ethernet cable out of the computer, then it really is an error; but the results are the same. The connection was lost. You will also get this error if you call the Disconnect method of TCPSocket.

103 The socket was unable to resolve the address that was specified.

A prime example of this would be a mistyped IP address, or a domain name of an unknown or unreachable host.

104 This error code is no longer used.
105 The address is currently in use.

This error will occur if you attempt to bind to a port that you have already bound to. An example of this would be setting up two listening sockets to try to listen on the same port.

106 This is an invalid state error, which means that the socket is not in the proper state to be doing a certain operation.

An example of this is calling the Write method before the socket is actually connected.

107 This error means that the port you specified is invalid.

This could mean that you entered a port number less than 0, or greater than 65,535. It could also mean that you do not have enough privileges to bind to that port. This happens under macOS and Linux if you are not running as root and try to bind to a port below 1024. You can only bind to ports less than 1024 if you have root privileges. A normal "Admin" user does not have root privileges.

108 This error indicates that your application has run out of memory.

These are not the only errors that are returned. For Windows, additional error codes are usually positive numbers in the range [10004, 11004]. For Windows error codes, see WinSock.h. MacOS and Linux use POSIX error codes. For a description of macOS and Linux error codes, see

e.g. error 64 is for "host is down".


The following example in the Error event handler displays the error code.