Class
FirewallPort
Description
Used to securely open and close ports on the Xojo Cloud firewall for when you need to connect to an outside service. As long as an instance to the object exists, the port remains open. If the object goes out of scope, is destroyed (set to Nil), or the app terminates, the firewall port is automatically closed.
Properties
Name |
Type |
Read-Only |
Shared |
---|---|---|---|
Methods
Name |
Parameters |
Returns |
Shared |
---|---|---|---|
Port As Integer, DataDirection As FirewallPort |
|||
Enumerations
FirewallPort.Direction
Direction
The direction that the port should allow data to pass through.
Enum |
---|
Incoming |
Outgoing |
Property descriptions
FirewallPort.IsOpen
IsOpen As Boolean
Returns True if the firewall port was successfully opened.
FirewallPort.NetworkInterface
NetworkInterface As NetworkInterface
Allows you to specify the network interface that you want to use for the firewall port. Defaults to the public interface.
Method descriptions
FirewallPort.Close
Close
Closes the firewall port.
FirewallPort.Constructor
Constructor(Port As Integer, DataDirection As FirewallPort)
Note
Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.
Use to securely open and close ports in a Xojo Cloud firewall.
Port: The port you wish to connect to (outgoing) or listen on (incoming). If you are creating an incoming connection, remember that you can't listen on a port < 1024 (they are reserved for system services). Ports 54320 through 54329 are reserved for use by Xojo for both incoming and outgoing connections. Use of these ports will result in an OutOfBoundsException.
DataDirection: The direction the initial data will be flowing. If your app will be connecting to an outside service, direction = XojoCloud.FirewallPort.Direction.Outgoing. If your app (or a helper app) will be listening on the port, DataDirection = XojoCloud.FirewallPort.Direction.Incoming.
This code opens firewall port 587:
Var fwp As New XojoCloud.FirewallPort(587, XojoCloud.FirewallPort.Direction.Outgoing)
fwp.Open() ' This call is synchronous.
If fwp.isOpen() Then
' Do what you need to do
fwp.Close() //Optional, but if you will not using the port, we recommend it.
End If
FirewallPort.Open
Open
Attempts to open the firewall port. This call is synchronous and may take a few seconds.
Notes
By default, the firewall on your Xojo Cloud server blocks all connections (other than port 80 and port 443) coming into and going out of the system unless a specific exception has been created. The problem with most firewall exceptions is that they are permanent, and because the are not created by the programmer that needs them, when they are no longer needed the exception is not removed and you end up with a security hole. Xojo Cloud solves this problem by using dynamic firewall port allocation. That is, you only open ports when you need them and they automatically close when you don't need them any more.
These are the values for the FirewallPort.Direction enumeration:
Value |
Description |
---|---|
Incoming |
Allow incoming data from the specified port. |
Outgoing |
Allow outgoing data to the specified port. |
Sample code
This code opens firewall port 587:
Var fwp As New XojoCloud.FirewallPort(587, XojoCloud.FirewallPort.Direction.Outgoing)
fwp.Open() ' This call is synchronous
If fwp.isOpen() Then
' Do what you need to do
fwp.Close() ' Optional, but if you will not using the port, we recommend it.
End If
Compatibility
All project types on all supported operating systems.