private void SendCallback(IAsyncResult ar) { try { // Retrieve the socket from the state object. FxTcpClientSocket pClientSocket = (FxTcpClientSocket)ar.AsyncState; // Complete sending the data to the remote device. int bytesSent = m_hSocket.EndSend(ar); OnSend((UInt32)bytesSent); } catch (SocketException e) { SNetEvent pEvent = new SNetEvent(); pEvent.eType = ENetEvtType.NETEVT_ERROR; pEvent.dwValue = (UInt32)e.SocketErrorCode; FxNetModule.Instance().PushNetEvent(this, pEvent); Disconnect(); return; } catch (Exception e) { SNetEvent pEvent = new SNetEvent(); pEvent.eType = ENetEvtType.NETEVT_ERROR; //pEvent.dwValue = (UInt32)e.HResult; FxNetModule.Instance().PushNetEvent(this, pEvent); Disconnect(); return; } }
private void ConnectCallback(IAsyncResult ar) { try { FxTcpClientSocket pClientSocket = (FxTcpClientSocket)ar.AsyncState; m_hSocket.EndConnect(ar); OnConnect(); } catch (SocketException e) { SNetEvent pEvent = new SNetEvent(); pEvent.eType = ENetEvtType.NETEVT_ERROR; pEvent.dwValue = (UInt32)e.SocketErrorCode; FxNetModule.Instance().PushNetEvent(this, pEvent); Disconnect(); } }