Unity3D and Sockets - C#

I'm just curious if it is possible to have custom socket networking with Unity3D? I just want to confirm.

I don't want to use the Unity provided network functions.

Here are two links I found that might be useful:

TCP/IP Client-Server Basics and Sockets in C#

and some sample code I wrote in another answer: TCP Client code

It is - you can use the standard .NET sockets

Try checking TcpClient in the MSDN reference: http://msdn.microsoft.com/en-us/library/system.net.sockets.tcpclient.aspx

There are other ways to go about it, but that is a good enough starting point

start with Microsoft MSDN , i recommend googling the internet tutorials too :
MSDN C# Sockets Programming

Check out the video of the “Unity, Network Code, and You” talk from Unite '12. The video archive is here. (Oddly, you can’t link directly to the individual video.) The talk outlines 4 ways to do networking in Unity, including sockets.

This question is for a long time ago, but if anyone else is wondering about using c# sockets for real-time communications in Unity:

Although it has some difficulties like threading(Unity is single thread) but it’s possible.


If you are interested, I have developed a Unity package which has necessary classes for establishing UDP connections and some working examples here.

Briefly it creates two threads for send & receive, properly lock’s thread’s access to shared resources and
provides queues and methods for sending and receiving packets. i have tested it on Windows & Android.