本文整理匯總了C#中System.Net.Sockets.TcpListener.Pending方法的典型用法代碼示例。如果您正苦於以下問題:C# TcpListener.Pending方法的具體用法?C# TcpListener.Pending怎麽用?C# TcpListener.Pending使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Net.Sockets.TcpListener
的用法示例。
在下文中一共展示了TcpListener.Pending方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: TcpListener
try{
// Use the Pending method to poll the underlying socket instance for client connection requests.
IPAddress ipAddress = Dns.Resolve("localhost").AddressList[0];
TcpListener tcpListener = new TcpListener(ipAddress, portNumber);
tcpListener.Start();
if (!tcpListener.Pending()) {
Console.WriteLine("Sorry, no connection requests have arrived");
}
else{
//Accept the pending client connection and return a TcpClient object initialized for communication.
TcpClient tcpClient = tcpListener.AcceptTcpClient();
// Using the RemoteEndPoint property.
Console.WriteLine("I am listening for connections on " +
IPAddress.Parse(((IPEndPoint)tcpListener.LocalEndpoint).Address.ToString()) +
"on port number " + ((IPEndPoint)tcpListener.LocalEndpoint).Port.ToString());