Professional Documents
Culture Documents
I want to create server socket where users will always be to connect, and to send
message only when I send them specific message,"CLIENT_ACTION"( they will know
when, client side is not important now). So basically I know when to expect message
from the client. But now, will they be able to connect on server socket, even if my
logic is running. Picture it like this: Chat starting when at least 2 clients
connects to server, but it has specific tasks to do with current connected
clients,and new clients should be able to connect to server, but not to participate
in current "round" until it is done.Then everything starts over again, with new
clients who connected in the meantime.
Will this code works as expected ? Will clients be able to connect while round is
ongoing?
How will I know that client will respond successfully? What if he doesn't answer
e.g in 30 sec, will I recieve empty buffer?
I generally need help with synchronous server settings becaues I couldn't find a
lot of documentation. This code is probably bad so I would like suggestions from
your side and is this achievable at all
class Program
{
private static Socket _serverSocket;
private static readonly List<Socket> _clientSockets = new List<Socket>();
private const int BUFFER_SIZE = 2048;
private const int PORT = 1582;
private static readonly byte[] buffer = new byte[BUFFER_SIZE];
private static bool isRoundActive = false;
}
}
}
}
return action;
}
}
catch (Exception ex)
{
return "something";
}
}