internal static void Init(IRpcServerContext value) { if (value != null) { // Use an object indirection to hold the HttpContext in the AsyncLocal, // so it can be cleared in all ExecutionContexts when its cleared. rpcContextCurrent.Value = new RpcContextHolder { Context = value }; } }
public TcpTransportManager(IPEndPoint endPoint, IRpcServerContext serverContext) { _sock = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); _sock.Bind(endPoint); _sock.Listen(100); _serverContext = serverContext; for (int i = 0; i < MIN_ACCEPT_CONCURRENCY; i++) { BeginAccept(); } }
public TcpTransportChannel(Socket socket, IRpcServerContext serverContext) { _id = Interlocked.Increment(ref _idCounter); _sock = socket; _serverContext = serverContext; _recvBuffer = new byte[BUFFER_SIZE]; _recvBufferOffset = 0; BeginReceive(BUFFER_SIZE); new Thread(ReadReceiveBuffer) { IsBackground = true }.Start(); }