/// <summary> /// start /// </summary> public void Start() { this._socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); this._socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); this._socket.Bind(new IPEndPoint(IPAddress.Any, this._port)); this._socket.DontFragment = true; this._pool = new AsyncSendPool(this._messageBufferSize, this._socket); var e = new SocketAsyncEventArgs(); e.RemoteEndPoint = new IPEndPoint(IPAddress.Any, 0); e.SetBuffer(new byte[this._messageBufferSize], 0, this._messageBufferSize); e.Completed += this.ReceiveCompleted; this.BeginReceive(e); }
/// <summary> /// start /// </summary> public void Start() { base.CheckDisposedWithException(); this._socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); this._socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); this._socket.Bind(new IPEndPoint(IPAddress.Any, this._port)); this._socket.DontFragment = true; this._pool = new AsyncSendPool(this._messageBufferSize, this._socket); for (int i = 0; i < this._receiveThreads; i++) { var e = new SocketAsyncEventArgs(); e.RemoteEndPoint = new IPEndPoint(IPAddress.Any, 0); e.SetBuffer(new byte[this._messageBufferSize], 0, this._messageBufferSize); e.Completed += new EventHandler <SocketAsyncEventArgs>(this.ReceiveCompleted); this.BeginReceive(e); } }
/// <summary> /// stop /// </summary> public void Stop() { this._socket.Close(); this._socket = null; this._pool = null; }
/// <summary> /// free /// </summary> /// <param name="disposing"></param> protected override void Free(bool disposing) { this._socket.Close(); this._socket = null; this._pool = null; }
/// <summary> /// start /// </summary> public void Start() { base.CheckDisposedWithException(); this._socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); this._socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); this._socket.Bind(new IPEndPoint(IPAddress.Any, this._port)); this._socket.DontFragment = true; this._pool = new AsyncSendPool(this._messageBufferSize, this._socket); for (int i = 0; i < this._receiveThreads; i++) { var e = new SocketAsyncEventArgs(); e.RemoteEndPoint = new IPEndPoint(IPAddress.Any, 0); e.SetBuffer(new byte[this._messageBufferSize], 0, this._messageBufferSize); e.Completed += new EventHandler<SocketAsyncEventArgs>(this.ReceiveCompleted); this.BeginReceive(e); } }