Esempio n. 1
0
        private static void ConnectInprocSockets(Socket boundSocket, PendingConnection connection)
        {
            boundSocket.IncreaseSequenceNumber();
            connection.BindPipe.SlotId = boundSocket.SlotId;

            // If bound socket doesn't receive identity we need to read from the pipe as we already
            // insert the message while creating the pipe pair
            if (!boundSocket.Options.ReceiveIdentity)
            {
                Frame frame;
                connection.BindPipe.TryRead(out frame);
                frame.Close();
            }

            int inHighWatermark = 0;
            int outHighWatermark = 0;

            if (boundSocket.Options.SendHighWatermark != 0 &&
                connection.Socket.Options.ReceiveHighwatermark != 0)
                inHighWatermark =
                    boundSocket.Options.SendHighWatermark + connection.Socket.Options.ReceiveHighwatermark;

            if (boundSocket.Options.ReceiveHighwatermark != 0 &&
                connection.Socket.Options.SendHighWatermark != 0)
                outHighWatermark =
                    boundSocket.Options.ReceiveHighwatermark + connection.Socket.Options.SendHighWatermark;

            // Set the highwatermarks now as before the bound highwater marks was missing
            connection.ConnectPipe.SetHighWatermarks(inHighWatermark,outHighWatermark);
            connection.BindPipe.SetHighWatermarks(outHighWatermark, inHighWatermark);

            BindCommand bindCommand = new BindCommand(boundSocket, connection.BindPipe);
            boundSocket.Process(bindCommand);

            CommandDispatcher.SendInprocConnected(connection.Socket);

            if (connection.Socket.Options.ReceiveIdentity)
            {
                Frame identity = new Frame();
                identity.Identity = true;
                connection.BindPipe.TryWrite(ref identity);
                connection.BindPipe.Flush();
            }
        }