SocketCore.Port

The port to bind on or connect to. On most operating systems, attempting to bind to a port less than 1024 causes a SocketCore.Error event to fire with an error number 107 unless the application is running with administrative permissions.

Syntax
Port( Integer ) as

Parameters
Integer |

# Notes

This is due to security features built into the underlying OS.

You need to set the port property explicitly before any call to Listen or Connect. This is because REALbasic will modify the Port property to reflect what the actual bound port is during the various stages of operation.

For instance, if you listen on port 8080 and a connection comes in, you can check the Port property to ensure that you're still listening on port 8080 (that you haven't the port hasn't been hijacked). Or, if you connect to a socket on port 8080, once the connection occurs, you can check to see what port the OS has bound you to. This will be a random-seeming port number.

This trick can be very useful when you do things like Listen on port 0. In that case, the OS will pick a port for you and listen on it. Then you can check the Port property to see which port the OS picked. This functionality is used for various protocols, such as FTP.