public void Connect(IPEndPoint remoteEndPoint) { var state = new SocketConnectState(this); BeginConnect(remoteEndPoint, buildSocketCallback, state); if (!connectEvent.WaitOne(settings.ConnectTimeout, false)) { connectEvent.Reset(); throw new SocketException((int) SocketError.TimedOut); } if (state.Exception != null) throw state.Exception; connectEvent.Reset(); BeginReceive(GetReceiveBuffer(), 0, settings.ReceiveBufferSize, SocketFlags.None, receiveCallback, null); }
public void Connect(IPEndPoint remoteEndPoint) { var state = new SocketConnectState(this); BeginConnect(remoteEndPoint, buildSocketCallback, state); if (!connectEvent.WaitOne(settings.ConnectTimeout, false)) { connectEvent.Reset(); throw new SocketException((int)SocketError.TimedOut); } if (state.Exception != null) { throw state.Exception; } connectEvent.Reset(); BeginReceive(GetReceiveBuffer(), 0, settings.ReceiveBufferSize, SocketFlags.None, receiveCallback, null); }