예제 #1
0
파일: Client.cs 프로젝트: xiataosky/proxy
        private void DataSent(IAsyncResult res)
        {
            try
            {
                if (!IsConnected())
                {
                    Disconnect();
                    return;
                }

                var sent = ((Socket)res.AsyncState).EndSend(res);
                if (sent < 0)
                {
                    Sock.Shutdown(SocketShutdown.Both);
                    Sock.Close();
                    return;
                }

                var data = new DataEventArgs(this, new byte[] { }, sent);
                OnDataSent(this, data);
            }
            catch (Exception ex)
            {
#if DEBUG
                Console.WriteLine(ex.ToString());
#endif
            }
        }
 public void Dispose(bool disposing)
 {
     if (Sock != null && Sock.Connected)
     {
         try
         {
             Sock.Shutdown(SocketShutdown.Both);
             Sock.Close();
             Sock = null;
         }
         catch
         {
         }
     }
 }
예제 #3
0
        public void Close(ESockerCloseType eType, int param, bool isPassiveClose)
        {
            bool result = false;

            if (SUCCESS(IsClosed))
            {
                goto Exit1;
            }
            IsClosed        = true;
            IsPassiveClosed = isPassiveClose;

            Sock.Shutdown(SocketShutdown.Send);

            result = LP.NetModule.EventMgr.PushTerminateEvent(this);
            if (LOG_ERROR(result))
            {
                goto Exit0;
            }

Exit1:
Exit0:
            return;
        }
예제 #4
0
 public void Close()
 {
     // Release the socket.
     Sock.Shutdown(SocketShutdown.Both);
     Sock.Close();
 }