# Getting Started

## Client Side

{% code title="" %}

```csharp
using CodeReaper;

// define exSocket object
exSocket sckClient = new exSocket();

public Form1()
{
    InitializeComponent();

    // Set default IP and Port
    sckClient.remoteIP = "127.0.0.1";
    sckClient.remotePort = 9001;

    // Link object with event handler
    sckClient.onConnect += SckClient_onConnect;
    sckClient.onDisconnect += SckClient_onDisconnect;
    sckClient.onDataArrival += SckClient_onDataArrival;

    // Set ConnectInterval (ms)
    sckClient.ConnectInterval = 1000;
    // Set AutoConnectEnable flag to true
    sckClient.AutoConnectEnable = true;
}

private void SckClient_onConnect(object sender)
{
    // Connected!
}

private void SckClient_onDisconnect(object sender)
{
    // Disconnected!
}

private void SckClient_onDataArrival(object sender, byte[] Data, int bytesRead)
{
    MessageBox.Show(Encoding.UTF8.GetString(Data));
}

```

{% endcode %}

## Server Side

```csharp
using CodeReaper;

// define exSocket object
exSocket sckServer = new exSocket();

public Form1()
{
    InitializeComponent();

    // Set Local Port to listen.
    sckServer.LocalPort = 9001;

    sckServer.onConnect += SckServer_onConnect;
    sckServer.onDisconnect += SckServer_onDisconnect;
    sckServer.onDataArrival += SckServer_onDataArrival;

    // call Listen()
    sckServer.Listen();
}

private void SckServer_onConnect(object sender)
{
    // Connected!
}

private void SckServer_onDisconnect(object sender)
{
    // Disconnected!
}

private void SckServer_onDataArrival(object sender, byte[] Data, int bytesRead)
{
    MessageBox.Show(Encoding.UTF8.GetString(Data));
}

```

## How to send data

```
now working....
```


---

# 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://codereaper.gitbook.io/exsocket/getting-started.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.
