26.7.txt
来自「《Microsoft Visual C# .NET 2003开发技巧大全》源代码」· 文本 代码 · 共 33 行
TXT
33 行
Listing 26.7 Connecting and Communicating with Infrared Clients
void ListenerThreadMethod()
{
int bytesRead = 0;
IrDAClient client = null; // the connecting client
Stream byteStream = null;
byte[] buffer = new byte[1024];
try
{
do
{
listener.Start();
client = listener.AcceptIrDAClient();
byteStream = client.GetStream();
bytesRead = byteStream.Read( buffer, 0, 1024 );
if( byteStream != null )
byteStream.Close();
if( client != null )
client.Close();
AddMessage( client.RemoteMachineName,
Encoding.ASCII.GetString( buffer, 0, bytesRead ));
} while (true);
}
finally
{
if( byteStream != null )
byteStream.Close();
if( client != null )
client.Close();
listener.Stop();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?