예제 #1
0
 public virtual void Connect(string ip, string port)
 {
     try
     {
         this.remoteIp   = ip;
         this.remotePort = port;
         this.socket     = TcpHelper.CreateSocket(ip, port);
     }
     catch (Exception ex)
     {
         ErrManager.RaiseError(new FxErrArgs(ErrLevel.Fatal, ex));
     }
 }
예제 #2
0
 public virtual void Send(SipMessage packet)
 {
     DebugWriter.WriteSendPacket(packet);
     try
     {
         TcpHelper.AsyncSend(this.socket, packet, this.SendCallback);
     }
     catch (SocketException ex)
     {
         Log.WriteLog(LogFile.Error, ex.ToString());
         ErrManager.RaiseError(new FxErrArgs(ErrLevel.Fatal, ex));
     }
 }
예제 #3
0
 public override void Send(SipMessage packet)
 {
     try
     {
         TcpHelper.AsyncSend(this.socket, packet, this.SendCallback);
     }
     catch (SocketException ex)
     {
         Log.WriteLog(LogFile.Debug, "ChatConnection Send异常:" + ex.ToString());
         //not throw fata error,keep main thread not exit
         ErrManager.RaiseError(new FxErrArgs(ErrLevel.Critical, ex));
     }
 }
예제 #4
0
        public virtual void SendCallback(IAsyncResult ar)
        {
            Socket socket = null;

            try
            {
                socket = ar as Socket;
            }
            catch (Exception exception)
            {
                string errInfo = string.Format("AysncSend:异步发送数据发生错误!:remoteip:{0},port:{1}", this.remoteIp, this.socket.LocalEndPoint.ToString());
                Log.WriteLog(LogFile.Error, exception.ToString());
                ErrManager.RaiseError(new FxErrArgs(ErrLevel.Fatal, exception));
            }
        }