I have the client side in C# running from Unity and it's just this
byte[] buffer = { 1 };
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
s.Connect(IP, PORT);
System.Int32 Result = s.Send(buffer);
Debug.Log(Result);
and the server side is written in C, it's really long so here is the place where I get the error
for(char i = 0; i < MAX_PLAYERS; ++i)
{
if(ClientSockets[i] == INVALID_SOCKET) break;
Result = recv(ClientSockets[i], Message, sizeof(Message), 0);
if (Result == SOCKET_ERROR)
{
unsigned long LastError = GetLastError();
if (LastError != 10035)
{
Error("recv failed.\n");
}
}
I've made the socket's non blocking with ioctlsocket(ClientSocket, FIONBIO, &iMode)
before putting them in the ClientSockets array.