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

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                              | Type                                                 | Read-Only | Shared |
|---------------------------------------------------|------------------------------------------------------|-----------|--------|
| `IsOpen<firewallport.isopen>`                     | `Boolean</api/data_types/boolean>`                   |           |        |
| `NetworkInterface<firewallport.networkinterface>` | `NetworkInterface</api/networking/networkinterface>` |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                     | Parameters                                                                                                    | Returns | Shared |
|------------------------------------------|---------------------------------------------------------------------------------------------------------------|---------|--------|
| `Close<firewallport.close>`              |                                                                                                               |         |        |
| `Constructor<firewallport.constructor0>` | Port As `Integer</api/data_types/integer>`, DataDirection As `FirewallPort.Direction<firewallport.direction>` |         |        |
| `Open<firewallport.open>`                |                                                                                                               |         |        |

## Enumerations

<div id="firewallport.direction">

<div class="rst-class">

forsearch

</div>

</div>

FirewallPort.Direction

### Direction

> The direction that the port should allow data to pass through.
>
> | Enum     |
> |----------|
> | Incoming |
> | Outgoing |

## Property descriptions

<div id="firewallport.isopen">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

FirewallPort.IsOpen

**IsOpen** As `Boolean</api/data_types/boolean>`

> Returns `True</api/language/true>` if the firewall port was successfully opened.

<div id="firewallport.networkinterface">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

FirewallPort.NetworkInterface

**NetworkInterface** As `NetworkInterface</api/networking/networkinterface>`

> Allows you to specify the network interface that you want to use for the firewall port. Defaults to the public interface.

## Method descriptions

<div id="firewallport.close">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

FirewallPort.Close

**Close**

> Closes the firewall port.

<div id="firewallport.constructor0">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

FirewallPort.Constructor

**Constructor**(Port As `Integer</api/data_types/integer>`, DataDirection As `FirewallPort.Direction<firewallport.direction>`)

> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> `Constructors</api/language/constructor>` are special methods called when you create an object with the `New</api/language/new>` keyword and pass in the parameters above.
>
> </div>
>
> 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</api/exceptions/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:
>
> ``` xojo
> 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
> ```

<div id="firewallport.open">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

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 <span class="title-ref">FirewallPort</span>.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:

``` xojo
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

|                       |     |
|-----------------------|-----|
| **Project Types**     | Web |
| **Operating Systems** | All |
