public void CompleteTunnel(ref SelectControl selectControl, Socket socket) { lock (connectedSocket) { if (connectedTunnel != null) { throw new InvalidOperationException("CodeBug: This tunnel has already been completed"); } // // Send all the buffered data // if (bufferLength > 0) { try { socket.Send(buffer.array, 0, bufferLength, SocketFlags.None); } catch (Exception) { selectControl.ShutdownDisposeAndRemoveReceiveSocket(connectedSocket); selectControl.ShutdownDisposeAndRemoveReceiveSocket(socket); return; } } connectedTunnel = new ConnectedTunnel(connectedSocket, socket); selectControl.UpdateHandler(socket, connectedTunnel.BToAHandler); } }
ConnectedTunnel connectedTunnel; // gets set when the other end connects public DisconnectedTunnel(Socket connectedSocket) { this.connectedSocket = connectedSocket; this.buffer = null; this.bufferLength = 0; this.connectedTunnel = null; }