예제 #1
0
            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
0
 public void OnConnect(BaseSocket sock)
 {
     sock.Write(sbuf, 5, 10);
 }