本文整理匯總了C#中bedrock.net.BaseSocket.Write方法的典型用法代碼示例。如果您正苦於以下問題:C# BaseSocket.Write方法的具體用法?C# BaseSocket.Write怎麽用?C# BaseSocket.Write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bedrock.net.BaseSocket
的用法示例。
在下文中一共展示了BaseSocket.Write方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnRead
public bool OnRead(BaseSocket sock, byte[] buf, int offset, int length)
{
string str = ENC.GetString(buf, offset, length);
Console.WriteLine("SR: " + str);
if (str.Contains("11111"))
{
sock.Write(ENC.GetBytes(@"HTTP/1.1 200 OK
Content-Length: 10
Content-Type: text/plain
1234567890"));
}
else if (str.Contains("22222"))
{
sock.Write(ENC.GetBytes(@"HTTP/1.1 200 OK
Content-Length: 10
Content-Type: text/plain
12345"));
sock.Write(ENC.GetBytes("67890"));
}
else if (str.Contains("33333"))
{
sock.Write(ENC.GetBytes(@"HTTP/1.1 200 OK
Content-Length: 20
Content-Type: text/plain
12345"));
// Turning off Nagle didn't fix this. Mrmph.
Thread.Sleep(300);
sock.Write(ENC.GetBytes("67890"));
Thread.Sleep(300);
sock.Write(ENC.GetBytes("12345"));
Thread.Sleep(300);
sock.Write(ENC.GetBytes("67890"));
}
return true;
}
示例2: OnConnect
public void OnConnect(BaseSocket sock)
{
sock.Write(sbuf, 5, 10);
}