public override void Connect(ConnOptEther optEth, int iTimeout, int iRetry) { try { m_tcpStream = new TcpClient(); var iar = m_tcpStream.BeginConnect(optEth.DstAddr, optEth.DstPort, null, null); if (!iar.IsCompleted) { if (!iar.AsyncWaitHandle.WaitOne(iTimeout)) { try { m_tcpStream.Close(); m_tcpStream.EndConnect(iar); } catch (Exception) { } throw new TimeoutException(); } } m_tcpStream.EndConnect(iar); m_tcpStream.NoDelay = true; SetTimeout(iTimeout); SetRetry(iRetry); m_conv = new bCAPPacketConverter(); m_lock = new object(); } catch (Exception ex) { throw ex; } }
public override void Connect(ConnOptEther optEth, int iTimeout, int iRetry) { try { m_ipEpSend = new IPEndPoint(IPAddress.Parse(optEth.DstAddr), optEth.DstPort); m_udpStream = new UdpClient( new IPEndPoint(IPAddress.Parse(optEth.SrcAddr), optEth.SrcPort) ); SetTimeout(iTimeout); SetRetry(iRetry); m_conv = new bCAPPacketConverter(); m_lock = new object(); } catch (Exception ex) { throw ex; } }