> For the complete documentation index, see [llms.txt](https://tariksavas.gitbook.io/tarnet/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tariksavas.gitbook.io/tarnet/docs/how-to-use/configurations/socketconfig.md).

# SocketConfig

`SocketConfig` is a `ScriptableObject` class used to configure network connections in Tarnet. It allows defining critical network settings such as the IP address, port number, and server capacity. `SocketConfig` can be created via the Unity Editor or dynamically at runtime using `ScriptableObject.CreateInstance`.

***

**Properties**

* **`ipAddress`**\
  **Description:** The IP address the socket will bind to or connect to.\
  **Default Value:** `127.0.0.1`\
  **Usage:** Use `127.0.0.1` for local connections or specify a valid IP address for external connections.
* **`port`**\
  **Description:** The port number used for the socket connection.\
  **Default Value:** `5555`\
  **Usage:** Ensure the port is not already in use by another application.
* **`serverCapacity`**\
  **Description:** The maximum number of clients the server can handle simultaneously.\
  **Default Value:** `10`\
  **Usage:** Adjust this based on the requirements of your project. For high traffic, increase this value as needed.

***

**How to Create SocketConfig**

1. **Through the Unity Editor** \
   Navigate to **Assets > Create > Tarnet > SocketConfig** to create a `SocketConfig` instance.

<figure><img src="https://2292636489-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWuBEhvlTwvopzQikhE0v%2Fuploads%2Fxlb87LJJj2trxV4SXztu%2Fsocket-config.png?alt=media&amp;token=df9063f7-0f4e-4108-a8ae-279d38d5bad1" alt=""><figcaption></figcaption></figure>

2. **Through Code**

```csharp
SocketConfig config = ScriptableObject.CreateInstance<SocketConfig>();
config.ipAddress = "127.0.0.1";
config.port = 12345;
config.serverCapacity = 100;
```

***

**Usages:**

`SocketConfig` is used with Tarnet's `SocketBuilder` class via the `SetSocketConfig` method, enabling centralized management of all network settings:

```csharp
SocketBuilder socketBuilder = new SocketBuilder();
socketBuilder.SetSocketConfig(config);
```

***

**Technical Details**

* **Flexibility:**\
  `SocketConfig` integrates seamlessly with `SocketBuilder`, offering a centralized configuration system that simplifies network management.
* **Dynamic Usage:**\
  The configuration object can be created and customized dynamically in code, providing flexibility during development.

This structure provides a reusable system for different projects, significantly simplifying the management of network configurations.
