# Class EasyHost

Listens for incoming [EasyClient](https://almightylks.gitbook.io/easycommunication/home/easyclient/class-easyclient) connections

**Namespace: EasyCommunication.Host.Connection**

**Assembly: EasyCommunication.dll**

#### Syntax <a href="#easycommunication_host_connection_easyhost_syntax" id="easycommunication_host_connection_easyhost_syntax"></a>

## Constructors <a href="#constructors" id="constructors"></a>

### EasyHost(Int32, Int32, IPAddress) <a href="#easycommunication_host_connection_easyhost__ctor_system_int32_system_int32_system_net_ipaddress_" id="easycommunication_host_connection_easyhost__ctor_system_int32_system_int32_system_net_ipaddress_"></a>

Creates an instance of [EasyHost](https://almightylks.gitbook.io/easycommunication/home/easyhost/class-easyhost) with a Heartbeat Interval, a Listening Port and a Listening Address.

#### Declaration

```
public EasyHost(int heartbeatInterval, int listeningPort, IPAddress listeningAddress)
```

#### Parameters

| Type                 | Name              | Description                                                                                  |
| -------------------- | ----------------- | -------------------------------------------------------------------------------------------- |
| System.Int32         | heartbeatInterval | Heartbeat Interval                                                                           |
| System.Int32         | listeningPort     | Listening Port for [TcpListener](#EasyCommunication_Host_Connection_EasyHost_TcpListener)    |
| System.Net.IPAddress | listeningAddress  | Listening Address for [TcpListener](#EasyCommunication_Host_Connection_EasyHost_TcpListener) |

## Properties <a href="#properties" id="properties"></a>

### ClientConnections <a href="#easycommunication_host_connection_easyhost_clientconnections" id="easycommunication_host_connection_easyhost_clientconnections"></a>

All Connections with received Heartbeats since last query, used by EasyCommunication.Host.Connection.Heartbeat.

#### Declaration

```
public Dictionary<TcpClient, int> ClientConnections { get; }
```

#### Property Value

| Type                                                                               | Description |
| ---------------------------------------------------------------------------------- | ----------- |
| System.Collections.Generic.Dictionary\<System.Net.Sockets.TcpClient, System.Int32> |             |

### EventHandler <a href="#easycommunication_host_connection_easyhost_eventhandler" id="easycommunication_host_connection_easyhost_eventhandler"></a>

EventHandler for EasyHost-events

#### Declaration

```
public HostEventHandler EventHandler { get; }
```

#### Property Value

| Type                                                                                                | Description |
| --------------------------------------------------------------------------------------------------- | ----------- |
| [HostEventHandler](https://almightylks.gitbook.io/easycommunication/home/easyhost/broken-reference) |             |

### ListeningPort <a href="#easycommunication_host_connection_easyhost_listeningport" id="easycommunication_host_connection_easyhost_listeningport"></a>

The port on which the Host is listening for incoming connections

#### Declaration

```
public int ListeningPort { get; }
```

#### Property Value

| Type         | Description |
| ------------ | ----------- |
| System.Int32 |             |

### TcpListener <a href="#easycommunication_host_connection_easyhost_tcplistener" id="easycommunication_host_connection_easyhost_tcplistener"></a>

The TcpListener used to listen for incoming connections.

#### Declaration

```
public TcpListener TcpListener { get; }
```

#### Property Value

| Type                           | Description |
| ------------------------------ | ----------- |
| System.Net.Sockets.TcpListener |             |

## Methods <a href="#methods" id="methods"></a>

### Close() <a href="#easycommunication_host_connection_easyhost_close" id="easycommunication_host_connection_easyhost_close"></a>

Closes the [TcpListener](#EasyCommunication_Host_Connection_EasyHost_TcpListener) from listening for connections

#### Declaration

### Open() <a href="#easycommunication_host_connection_easyhost_open" id="easycommunication_host_connection_easyhost_open"></a>

Open the [TcpListener](#EasyCommunication_Host_Connection_EasyHost_TcpListener) to listen for connections

#### Declaration

### SendData\<T>(T, TcpClient) <a href="#easycommunication_host_connection_easyhost_senddata__1___0_system_net_sockets_tcpclient_" id="easycommunication_host_connection_easyhost_senddata__1___0_system_net_sockets_tcpclient_"></a>

Sends data to the specified receiver

#### Declaration

```
public SendStatus SendData<T>(T data, TcpClient receiver)
```

#### Parameters

| Type                         | Name     | Description          |
| ---------------------------- | -------- | -------------------- |
| T                            | data     | Data to send         |
| System.Net.Sockets.TcpClient | receiver | Receiver of the data |

#### Returns

| Type                                                                                             | Description |
| ------------------------------------------------------------------------------------------------ | ----------- |
| [SendStatus](https://almightylks.gitbook.io/easycommunication/home/shared-types/enum-sendstatus) |             |

#### Type Parameters

| Name | Description                                                         |
| ---- | ------------------------------------------------------------------- |
| T    | Custom Type which has to be either JsonConvert'able or Serializable |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://almightylks.gitbook.io/easycommunication/home/easyhost/class-easyhost.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
