Connecting Unity Clients to a Dedicated Server | C# Networking Tutorial - Part 1

Tom Weiland · 458K views · 2019 · 12:29

Open on YouTube

Game programming & enginesNetworking & internet infrastructureIndie game developmenttutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it as the tutorial behind their Unity TCP client and server code, especially when asking about errors in code copied from it.

Recommended by 2 people across 2 different months, 2020 to 2021.

What it is

Part 1 of Tom Weiland's C# networking tutorial series, showing how to set up a TCP connection between a dedicated server application and a Unity client. It is a screen-recorded coding walkthrough, and the description notes the series is outdated and points to a newer version.

What people said

Recommends Lotan · 2020-05 · Stack Overflow · on “Fundamental Networking Understanding”

Yes, it is possible, with virtual hosts, virtual machines. If you are working in windows, take a look at XAMPP or WAMPP if you are in a Mac. This is a little big larger: 127.0.0.1 is the localhost (basically, yourself) also known as loopback adress. And 0.0.0.0 is a non-routable meta-adress. Basically it serves to designate invalid targets, it's like a placeholder for "unknown" adresses. Serves to designate invalid targets doesn't means that is an invalid adress! In your context, if you're using the 0.0.0.0 as a server it means "all IPv4 adresses on the local machine". If a host has two IP addresses, 192.168.1.1 and 10.1.2.1, and a server running on the host listens on 0.0.0.0, it will be re

Recommends Kyota.exe · 2021-12 · Stack Overflow · on “Unity TCP client: connection to a server”

First of all, at the top of your script: using System; using System.Net.Sockets; Then, create an instance of TcpClient and begin the connection: socket = new TcpClient { // dataBufferSize is in bytes ReceiveBufferSize = dataBufferSize, SendBufferSize = dataBufferSize }; socket.BeginConnect(ip, port, ConnectCallback, socket); In ConnectCallback() : private void ConnectCallback(IAsyncResult asyncResult) { socket.EndConnect(asyncResult); if (!socket.Connected) return; // stream is a NetworkStream you should declare somewhere stream = socket.GetStream(); // receiveBuffer is a byte[] you should declare somewhere receiveBuffer = new byte[dataBufferSize]; stream.BeginRead(receiveBuffer, 0, dataBuff

Cites slackers · 2020-04 · Stack Overflow · on “C# cannot convert from "Gameserver.Client.TCP" to "Sytem.Net.Sockets.TcpClient"”

I am trying to set up a test server for a simple Game and I am following a tutorial ( [this video] ). The problematic bit of code is: using System; using System.Collections.Generic; using System.Text; using System.Net; using System.Net.Sockets; namespace GameServer { class Client { public static int dataBufferSize = 4096; public int id; public TcpClient tcp; public Client(int _clientId) { id = _clientId; tcp = new TCP(id); } public class TCP { public TcpClient socket; private readonly int id; private NetworkStream stream; private byte[] receiveBuffer; public TCP(int _id) { id = _id; } } } } Whenever I try to run the program I get the error from the title because of this block of code(precisely th