Mercurial > hg > ucis.core
changeset 105:4ba4fd48e1da
Removed old TCP socket (non)blocking code
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Sat, 11 Oct 2014 14:06:11 +0200 |
parents | 327be9216006 |
children | a03e6ad0051f |
files | Net/TCPServer.cs Net/TCPStream.cs |
diffstat | 2 files changed, 2 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/Net/TCPServer.cs Sat Oct 11 14:05:41 2014 +0200 +++ b/Net/TCPServer.cs Sat Oct 11 14:06:11 2014 +0200 @@ -88,7 +88,6 @@ _Listener = new Socket(af, SocketType.Stream, ProtocolType.Tcp); - _Listener.Blocking = false; _Listener.Bind(new IPEndPoint(af == AddressFamily.InterNetworkV6 ? IPAddress.IPv6Any : IPAddress.Any, Port)); _Listener.Listen(25); _ThrottleCounter = _ThrottleBurst; @@ -184,7 +183,6 @@ internal Client(Socket Socket, TCPServer Server) : base(Socket) { _Server = Server; - Socket.Blocking = true; base.Closed += _Stream_Closed; this.Tag = Server; } @@ -197,11 +195,8 @@ bool CloseSocket = true; try { try { - base.Blocking = true; //base.NoDelay = true; base.ReadTimeout = 5000; - base.WriteBufferSize = 1024 * 10; - base.ReadBufferSize = 1024 * 10; //Console.WriteLine("TCPServer: Accepted connection from " + base.Socket.RemoteEndPoint.ToString()); _MagicNumber = (byte)base.PeekByte(); } catch (TimeoutException ex) {
--- a/Net/TCPStream.cs Sat Oct 11 14:05:41 2014 +0200 +++ b/Net/TCPStream.cs Sat Oct 11 14:06:11 2014 +0200 @@ -19,7 +19,6 @@ private ulong _BytesWritten; private ulong _BytesRead; private DateTime _StartTime; - private bool _Blocking; public event EventHandler Closed; @@ -27,7 +26,6 @@ _Socket = Socket; _HasPeekByte = false; _StartTime = DateTime.Now; - _Blocking = _Socket.Blocking; } public Socket Socket { @@ -39,11 +37,8 @@ } public bool Blocking { - get { return _Blocking; } - set { - Socket.Blocking = value; - _Blocking = value; - } + get { return _Socket.Blocking; } + set { Socket.Blocking = value; } } public bool NoDelay { @@ -91,7 +86,6 @@ } catch (SocketException ex) { switch (ex.SocketErrorCode) { case SocketError.WouldBlock: - _Socket.Blocking = _Blocking; throw new TimeoutException("The receive operation would block", ex); case SocketError.TimedOut: throw new TimeoutException("The receive operation timed out", ex); @@ -212,7 +206,6 @@ } catch (SocketException ex) { switch (ex.SocketErrorCode) { case SocketError.WouldBlock: - _Socket.Blocking = _Blocking; throw new TimeoutException("The send operation would block", ex); case SocketError.TimedOut: throw new TimeoutException("The send operation timed out", ex);