comparison Net/HTTP.cs @ 45:8df7f4dc5615

HTTP Server: enable KeepAlive option on TCP sockets
author Ivo Smits <Ivo@UCIS.nl>
date Wed, 12 Jun 2013 23:20:21 +0200
parents fba35b87da32
children ba4e2cb031e0
comparison
equal deleted inserted replaced
44:5a2b51b0d71b 45:8df7f4dc5615
58 58
59 public void Dispose() { 59 public void Dispose() {
60 if (Listener != null) Listener.Close(); 60 if (Listener != null) Listener.Close();
61 } 61 }
62 62
63 public void HandleClient(Socket client) {
64 new HTTPContext(this, client);
65 }
66
63 bool TCPServer.IModule.Accept(TCPStream stream) { 67 bool TCPServer.IModule.Accept(TCPStream stream) {
64 new HTTPContext(this, stream); 68 new HTTPContext(this, stream);
65 return false; 69 return false;
66 } 70 }
67 } 71 }
101 this.Server = server; 105 this.Server = server;
102 this.Socket = socket; 106 this.Socket = socket;
103 if (socket != null) { 107 if (socket != null) {
104 this.LocalEndPoint = socket.LocalEndPoint; 108 this.LocalEndPoint = socket.LocalEndPoint;
105 this.RemoteEndPoint = socket.RemoteEndPoint; 109 this.RemoteEndPoint = socket.RemoteEndPoint;
110 if (socket.ProtocolType == ProtocolType.Tcp) socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
106 if (stream == null) stream = new NetworkStream(socket, true); 111 if (stream == null) stream = new NetworkStream(socket, true);
107 } 112 }
108 Init(stream); 113 Init(stream);
109 } 114 }
110 115