---
title: roTCPServer
slug: develop/rotcpserver
docTags: 
createdAt: 2025-03-26T17:39:57.982Z
---

The JavaScript equivalent is net.socket.

## ifTCPServerInstance

**GetFailureReason() As String**

Yields additional useful information if an *roTCPServer* method fails.

**SetPort(port As Object)**

Sets the message port that will receive events from an roTCPServer instance.

**BindToPort(port As Dynamic) As Boolean**

Prepares to accept incoming TCP connections on the specified port. Passing an integer to this method will specify a standard port number. This method can also accept an associative array to provide more control over the binding. The associative array must contain the `port` but can also contain the `interface` name. This method returns `True` upon success and `False` upon failure.

- `port` <font color="#704ae0">integer</font>: The local port number to bind to.
- `interface` <font color="#704ae0">integer</font><font color="#0C121D"> or </font><font color="#704ae0">string</font>: Either the name of a network interface as a string (such as "eth0" or "wlan0") or the integer associated with the network interface index:
  - -1: Any (this is the default value)
  - 0: Ethernet
  - 1: WiFi
  - 2: Modem
  - 32767: Loopback (i.e. TCP connections can only be established by internal sources)

## ifUserData

**SetUserData(a As Object)&#xA0;**

Supplies an object that will be provided by every event called by an roTCPServer instance.

**GetUserData() As Object**

Returns the user data that has previously been set via `SetUserData()`. It will return `Invalid` if no data has been set.

