本文整理汇总了C#中SocketClient.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# SocketClient.Dispose方法的具体用法?C# SocketClient.Dispose怎么用?C# SocketClient.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SocketClient
的用法示例。
在下文中一共展示了SocketClient.Dispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StopInstance
public static void StopInstance(SocketClient client)
{
Java.Lang.Process shellProcess = instances[client];
instances.Remove(client);
client.Shutdown();
client.Dispose();
shellProcess.Destroy();
}
示例2: OnConnect
/// <summary>
/// Callback used to accept a connection on the server socket
/// </summary>
/// <param name="asyncResult">The result of the asynchronous operation</param>
/// <remarks>
/// <para>
/// On connection adds to the list of connections
/// if there are two many open connections you will be disconnected
/// </para>
/// </remarks>
private void OnConnect(IAsyncResult asyncResult)
{
try
{
// Block until a client connects
Socket socket = m_serverSocket.EndAccept(asyncResult);
LogLog.Debug(declaringType, "Accepting connection from ["+socket.RemoteEndPoint.ToString()+"]");
SocketClient client = new SocketClient(socket);
int currentActiveConnectionsCount = m_clients.Count;
if (currentActiveConnectionsCount < MAX_CONNECTIONS)
{
try
{
client.Send("TelnetAppender v1.0 (" + (currentActiveConnectionsCount + 1) + " active connections)\r\n\r\n");
AddClient(client);
}
catch
{
client.Dispose();
}
}
else
{
client.Send("Sorry - Too many connections.\r\n");
client.Dispose();
}
}
catch
{
}
finally
{
if (m_serverSocket != null)
{
m_serverSocket.BeginAccept(new AsyncCallback(OnConnect), null);
}
}
}