Multiple Client Connection Simultaneously
I am working on Server client online game on which multiple player can play. But the problem is that
connection can me made one at a time. If we make more than one connection simultaneouly then game will
hung. I Have implement this with the tcplistener . Can I implements this with asynchronouly. If yes then
how can I achive multiple connection and receive and send message from the clients.
my server code is :
public ServerForm()
{
processor = new Thread(new ThreadStart(StartListening));
processor.Start();
}
listener = new TcpListener(clsGetIpAddress.PortNo);
listener.Start();
while (true)
{
try
{
lock(this)
{
Socket s = listener.AcceptSocket() ;
clientsocket = s;
clientservice = new Thread(new ThreadStart(ServiceClient));
clientservice.Start();
}
}
Client Code Is:
public void Connect() if(connected) }
{
EstablishConnection();
{
RegisterWithServer();
receive = new Thread(new ThreadStart(ReceiveChat));
receive.Start();
}
try sr = new StreamReader(ns); }
private void EstablishConnection()
{
{
clientsocket = new TcpClient(serveraddress,serverport);
ns = clientsocket.GetStream();
connected = true;
Catch{}
}

