# Class EasyClient

Establish a connection and communicate with an [EasyHost](https://almightylks.gitbook.io/easycommunication/home/easyhost/class-easyhost)

**Namespace: EasyCommunication.Client.Connection**

**Assembly: EasyCommunication.dll**

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

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

### EasyClient() <a href="#easycommunication_client_connection_easyclient__ctor" id="easycommunication_client_connection_easyclient__ctor"></a>

#### Declaration

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

### ClientConnected <a href="#easycommunication_client_connection_easyclient_clientconnected" id="easycommunication_client_connection_easyclient_clientconnected"></a>

Whether or not the Client is connected with an

#### Declaration

```
public bool ClientConnected { get; }
```

#### Property Value

| Type           | Description |
| -------------- | ----------- |
| System.Boolean |             |

### Connection <a href="#easycommunication_client_connection_easyclient_connection" id="easycommunication_client_connection_easyclient_connection"></a>

#### Declaration

```
public Connection? Connection { get; set; }
```

#### Property Value

| Type                                                                                                              | Description |
| ----------------------------------------------------------------------------------------------------------------- | ----------- |
| System.Nullable<[Connection](https://almightylks.gitbook.io/easycommunication/home/easyclient/struct-connection)> |             |

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

EventHandler for EasyClient-events

#### Declaration

```
public ClientEventHandler EventHandler { get; }
```

#### Property Value

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

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

### ConnectToHost(IPAddress, Int32) <a href="#easycommunication_client_connection_easyclient_connecttohost_system_net_ipaddress_system_int32_" id="easycommunication_client_connection_easyclient_connecttohost_system_net_ipaddress_system_int32_"></a>

#### Declaration

```
public void ConnectToHost(IPAddress address, int port)
```

#### Parameters

| Type                 | Name    | Description             |
| -------------------- | ------- | ----------------------- |
| System.Net.IPAddress | address | IPAddress to connect to |
| System.Int32         | port    | Port to connect to      |

### DisconnectFromHost() <a href="#easycommunication_client_connection_easyclient_disconnectfromhost" id="easycommunication_client_connection_easyclient_disconnectfromhost"></a>

#### Declaration

```
public void DisconnectFromHost()
```

### SendData\<T>(T) <a href="#easycommunication_client_connection_easyclient_senddata__1___0_" id="easycommunication_client_connection_easyclient_senddata__1___0_"></a>

Sends data to the connected [EasyHost](https://almightylks.gitbook.io/easycommunication/home/easyhost/class-easyhost)

#### Declaration

```
public SendStatus SendData<T>(T data)
```

#### Parameters

| Type | Name | Description  |
| ---- | ---- | ------------ |
| T    | data | Data to send |

#### 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/easyclient/class-easyclient.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.
