Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/michal34512/tcp-connection-unity

This is a basic C# Unity implementation of a TCP connection between two hosts
https://github.com/michal34512/tcp-connection-unity

Last synced: 15 days ago
JSON representation

This is a basic C# Unity implementation of a TCP connection between two hosts

Awesome Lists containing this project

README

        

# TCP Connection with Unity
Simple connetion between two hosts based on TCP protocol.

# Establishing connection
Server:
```diff
# Starting server
Connection.Port = 7777;
Connection.Start_Connection(Connection.ConnectionRole.Server);
```
Client:
```diff
# Connecting to server
Connection.Port = 7777;
Connection.IpServ = "127.0.0.1";
Connection.Start_Connection(Connection.ConnectionRole.Client);
```

# Sending & receiving messages
Sending:
```diff
# Sending messages
string mess = Console.ReadLine();
Connection.SendMessage(Encoding.UTF8.GetBytes(mess));
```
Receiving:
```diff
# Receive messages
List messages = Connection.ReceiveMessages();
if (messages != null)
foreach (byte[] mess in messages)
{
Console.WriteLine(Encoding.UTF8.GetString(mess));
}
```