B
bernardpace
Hi,
I am doing as shown below below. Now since for every client that
connects a new call is being made, when a client finishes the
CloseClientCommunication method is called. In case two clients or more
clients terminate communication simulateneously, what would be the
behaviour of the CloseClientCommunication method.
Also, as given in the ClientCommunication method, the clientID is being
given as a parameter in the method and finally is being returned. Is
there a way to avoid the need of having to return this clientID?
pubilc delegate int ClientCommunicationDelegate(int clientID);
while(true)
{
Socket client = listener.AcceptSocket();
if (client.Connected == true)
{
ClientCommunicationDelegate del = new
ClientCommunicationDelegate(this.ClientCommunication);
AsyncCallback cb = new AsyncCallback(this.CloseClientCommunication);
IAsyncResult ar = del.BeginInvoke(this.totalClients, cb, null);
totalClients++; } // end if
} // end while loop
public int ClientCommunication(int clientID)
{
...
return clientID;
}
public void CloseClientCommunication(IAsyncResult ar)
{
while (ar.AsyncWaitHandle.WaitOne() == false){}
ClientCommunicationDelegate del =
(ClientCommunicationDelegate)((AsyncResult)ar).AsyncDelegate;
int clientID = del.EndInvoke(ar);
}
Can someone help me out
Thanks in Advance
I am doing as shown below below. Now since for every client that
connects a new call is being made, when a client finishes the
CloseClientCommunication method is called. In case two clients or more
clients terminate communication simulateneously, what would be the
behaviour of the CloseClientCommunication method.
Also, as given in the ClientCommunication method, the clientID is being
given as a parameter in the method and finally is being returned. Is
there a way to avoid the need of having to return this clientID?
pubilc delegate int ClientCommunicationDelegate(int clientID);
while(true)
{
Socket client = listener.AcceptSocket();
if (client.Connected == true)
{
ClientCommunicationDelegate del = new
ClientCommunicationDelegate(this.ClientCommunication);
AsyncCallback cb = new AsyncCallback(this.CloseClientCommunication);
IAsyncResult ar = del.BeginInvoke(this.totalClients, cb, null);
totalClients++; } // end if
} // end while loop
public int ClientCommunication(int clientID)
{
...
return clientID;
}
public void CloseClientCommunication(IAsyncResult ar)
{
while (ar.AsyncWaitHandle.WaitOne() == false){}
ClientCommunicationDelegate del =
(ClientCommunicationDelegate)((AsyncResult)ar).AsyncDelegate;
int clientID = del.EndInvoke(ar);
}
Can someone help me out
Thanks in Advance