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
ipAddressDescription: The IP address the socket will bind to or connect to. Default Value:127.0.0.1Usage: Use127.0.0.1for local connections or specify a valid IP address for external connections.portDescription: The port number used for the socket connection. Default Value:5555Usage: Ensure the port is not already in use by another application.serverCapacityDescription: The maximum number of clients the server can handle simultaneously. Default Value:10Usage: Adjust this based on the requirements of your project. For high traffic, increase this value as needed.
How to Create SocketConfig
Through the Unity Editor Navigate to Assets > Create > Tarnet > SocketConfig to create a
SocketConfiginstance.

Through Code
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:
SocketBuilder socketBuilder = new SocketBuilder();
socketBuilder.SetSocketConfig(config);Technical Details
Flexibility:
SocketConfigintegrates seamlessly withSocketBuilder, 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.
Last updated