예제 #1
0
 void StartConnectingSocket(IPAddress addr, int port)
 {
     socket = new System.Net.Sockets.Socket(addr.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
     try {
         socket.BeginConnect(addr, port, (ar) => {
             try {
                 socket.EndConnect(ar);
                 loop.NonBlockInvoke(connectedCallback);
             } catch {
             }
         }, null);
     } catch {
     }
 }
예제 #2
0
파일: Socket.cs 프로젝트: aaronfeng/manos
 private void StartConnectingSocket(IPAddress addr, int port)
 {
     StartTimeout();
     socket = new Socket(addr.AddressFamily,
                         SocketType.Stream,
                         ProtocolType.Tcp);
     try
     {
         socket.BeginConnect(addr, port, (ar) =>
         {
             try
             {
                 socket.EndConnect(ar);
                 if (Connected != null)
                 {
                     loop.NonBlockInvoke(delegate
                     {
                         Connected(this);
                     });
                 }
             }
             catch
             {
                 OnError();
             }
         }, null);
     }
     catch
     {
         OnError();
     }
 }
예제 #3
0
        void OnReadDone(IAsyncResult ar)
        {
            int result = stream.EndRead(ar);

            if (result > 0)
            {
                loop.NonBlockInvoke(delegate {
                    RaiseData(new ByteBuffer(readBuffer, 0, result));
                    ReadNextBuffer();
                });
            }
            else
            {
                loop.NonBlockInvoke(delegate {
                    PauseReading();
                    RaiseEndOfStream();
                });
            }
        }