本文整理匯總了C#中bedrock.net.BaseSocket類的典型用法代碼示例。如果您正苦於以下問題:C# BaseSocket類的具體用法?C# BaseSocket怎麽用?C# BaseSocket使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BaseSocket類屬於bedrock.net命名空間,在下文中一共展示了BaseSocket類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnInvalidCertificate
public bool OnInvalidCertificate(BaseSocket sock,
System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Security.Cryptography.X509Certificates.X509Chain chain,
System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return false;
}
示例2: OnError
public void OnError(BaseSocket sock, Exception ex)
{
lock (done)
{
succeeded = false;
errorMessage = ex.Message;
Monitor.Pulse(done);
}
}
示例3: 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;
}
示例4: OnConnect
/// <summary>
/// Outbound connection was connected.
/// </summary>
/// <param name="sock">Connected socket.</param>
public virtual void OnConnect(BaseSocket sock)
{
}
示例5: OnError
/// <summary>
/// An error happened in processing. The socket is no longer open.
/// </summary>
/// <param name="sock">Socket in error</param>
/// <param name="ec">Exception that caused the error</param>
public virtual void OnError(BaseSocket sock, System.Exception ec)
{
}
示例6: OnWrite
/// <summary>
///
/// </summary>
/// <param name="sock"></param>
/// <param name="buf"></param>
/// <param name="offset"></param>
/// <param name="length"></param>
public virtual void OnWrite(BaseSocket sock, byte[] buf, int offset, int length)
{
m_listener.OnWrite(sock, buf, offset, length);
}
示例7:
void ISocketEventListener.OnInit(BaseSocket newSock)
{
}
示例8: OnWrite
public void OnWrite(BaseSocket sock, byte[] buf, int offset, int length)
{
System.Diagnostics.Debug.WriteLine(ENC.GetString(buf, offset, length));
sock.Close();
}
示例9: OnError
/// <summary>
///
/// </summary>
/// <param name="sock"></param>
/// <param name="ex"></param>
public virtual void OnError(BaseSocket sock, System.Exception ex)
{
m_listener.OnError(sock, ex);
}
示例10: OnInit
public void OnInit(BaseSocket new_sock)
{
}
示例11: OnWrite
/// <summary>
/// Bytes were written to the socket.
/// </summary>
/// <param name="sock">The socket that was written to.</param>
/// <param name="buf">The bytes that were written.</param>
/// <param name="offset">Offset into the buffer to start at</param>
/// <param name="length">Number of bytes to use out of the buffer</param>
public virtual void OnWrite(BaseSocket sock, byte[] buf, int offset, int length)
{
}
示例12: OnConnect
public void OnConnect(BaseSocket sock)
{
sock.Write(sbuf, 5, 10);
}
示例13: catch
bool ISocketEventListener.OnRead(BaseSocket sock, byte[] buf, int offset, int length)
{
int tim = (int)m_listener[Options.KEEP_ALIVE];
if (tim > 0)
m_timer.Change(tim, tim);
m_listener.BytesRead(buf, offset, length);
try
{
m_elements.Push(buf, offset, length);
}
catch (Exception e)
{
((ISocketEventListener)this).OnError(sock, e);
sock.Close();
return false;
}
return true;
}
示例14: OnClose
public void OnClose(BaseSocket sock)
{
}
示例15: OnAccept
public bool OnAccept(BaseSocket newsocket)
{
newsocket.RequestRead();
return false;
}