TODO(benvanik): generalize this into an IPC channel
325920
function(e) {
    // This is a packet from the wtf.ipc.MessageChannel type.
    var data = e.data;
    if (!data ||
        !data['wtf_ipc_connect_token'] ||
        !data['data']['hello']) {
      return;
    }

    // Stop snooping.
    e.preventDefault();
    e.stopPropagation();
    window.removeEventListener('message', waiter, true);

    if (opt_callback) {
      opt_callback.call(opt_scope, e.source);
    }
    e.source.focus();
  }
293606
function blockFromRpc (blockParams, uncles) {
  uncles = uncles || []
  const block = new Block({
    transactions: [],
    uncleHeaders: []
  })
  block.header = blockHeaderFromRpc(blockParams)

  block.transactions = (blockParams.transactions || []).map(function (_txParams) {
    const txParams = normalizeTxParams(_txParams)
    // override from address
    const fromAddress = ethUtil.toBuffer(txParams.from)
    delete txParams.from
    const tx = new Transaction(txParams)
    tx._from = fromAddress
    tx.getSenderAddress = function () { return fromAddress }
    // override hash
    const txHash = ethUtil.toBuffer(txParams.hash)
    tx.hash = function () { return txHash }
    return tx
  })
  block.uncleHeaders = uncles.map(function (uncleParams) {
    return blockHeaderFromRpc(uncleParams)
  })

  return block
}
217135
private Producer<EncodedImage> newEncodedCacheMultiplexToTranscodeSequence(
      Producer<EncodedImage> inputProducer) {
    if (WebpSupportStatus.sIsWebpSupportRequired &&
        (!mWebpSupportEnabled || WebpSupportStatus.sWebpBitmapFactory == null)) {
      inputProducer = mProducerFactory.newWebpTranscodeProducer(inputProducer);
    }
    if (mDiskCacheEnabled) {
      inputProducer = newDiskCacheSequence(inputProducer);
    }
    EncodedMemoryCacheProducer encodedMemoryCacheProducer =
        mProducerFactory.newEncodedMemoryCacheProducer(inputProducer);
    return mProducerFactory.newEncodedCacheKeyMultiplexProducer(encodedMemoryCacheProducer);
  }
982286
public static void mlock(Pointer addr, long len) {

        int res = Delegate.mlock(addr, new NativeLong(len));
        if(res != 0) {
            if(logger.isDebugEnabled()) {
                logger.debug("Mlock failed probably because of insufficient privileges, errno:"
                             + errno.strerror() + ", return value:" + res);
            }
        } else {
            if(logger.isDebugEnabled())
                logger.debug("Mlock successfull");

        }

    }
53032
def join
      ipc = Thread.new { @ipc_server.join && stop }
      web = Thread.new { @web_server.join && stop }
      ipc.join
      web.join
      @irc_client.join
    end
1072067
function appender(configuration)
{
	var socket = dgram.createSocket('udp4');

	return function(loggingEvent)
	{
		var loggingObject =
		{
			name: loggingEvent.categoryName,
			message: layout(loggingEvent),
			severity: loggingEvent.level.level,
			severityText: loggingEvent.level.levelStr,
		};

		if (configuration.application)
		{
			loggingObject.application = configuration.application;
		}

		if (configuration.environment)
		{
			loggingObject.environment = configuration.environment;
		}

		if (MDC && MDC.active)
		{
			Object.keys(MDC.active).forEach(function(key)
			{
				loggingObject[key] = MDC.active[key];
			});
		}

		send(socket, configuration.host, configuration.port, loggingObject);
	};
}
1221392
private ChannelInitializer<SocketChannel> getChannelInitializer(final PravegaNodeUri location,
                                                                    final FlowHandler handler) {
        final SslContext sslCtx = getSslContext();

        return new ChannelInitializer<SocketChannel>() {
            @Override
            public void initChannel(SocketChannel ch) throws Exception {
                ChannelPipeline p = ch.pipeline();
                if (sslCtx != null) {
                    SslHandler sslHandler = sslCtx.newHandler(ch.alloc(), location.getEndpoint(), location.getPort());

                    if (clientConfig.isValidateHostName()) {
                        SSLEngine sslEngine = sslHandler.engine();
                        SSLParameters sslParameters = sslEngine.getSSLParameters();
                        sslParameters.setEndpointIdentificationAlgorithm("HTTPS");
                        sslEngine.setSSLParameters(sslParameters);
                    }
                    p.addLast(sslHandler);
                }
                p.addLast(
                        new ExceptionLoggingHandler(location.getEndpoint()),
                        new CommandEncoder(handler.getBatchSizeTracker()),
                        new LengthFieldBasedFrameDecoder(WireCommands.MAX_WIRECOMMAND_SIZE, 4, 4),
                        new CommandDecoder(),
                        handler);
            }
        };
    }
914550
private IoBuffer encodeClientBW(ClientBW clientBW) {
        final IoBuffer out = IoBuffer.allocate(5);
        out.putInt(clientBW.getBandwidth());
        out.put(clientBW.getLimitType());
        return out;
    }
963579
function emitSIGINT() {
    if (rl) {
        rl.close()
        rl = null
    }
    if (ipcListener) {
        process.removeListener("message", ipcListener)
        ipcListener = null
    }

    emitter.emit("SIGINT")
}
840592
function  WriteIpAddr (buffer, offset, ipstring) {
    var addr= ipstring.split('.');
    buffer.writeUInt8(parseInt(addr[3]), offset);
    buffer.writeUInt8(parseInt(addr[2]), offset + 1);
    buffer.writeUInt8(parseInt(addr[1]), offset + 2);
    buffer.writeUInt8(parseInt(addr[0]), offset + 3);
}
69313
private String toCidrNotation(String addr, String mask) {
        return addr + "/" + pop(toInteger(mask));
    }
204252
function convToNum(ipstr) {
    let ret = 0;
    let mul = 256*256*256;
    ipstr.split('.').forEach((numstr)=>{
        ret += parseInt(numstr)*mul;
        mul >>= 8;
    });
    return ret;
}
1093448
private String createTransmitter() {

        // Cheated.  Should have checked the type.
        PushBufferDataSource pbds = (PushBufferDataSource) dataOutput;
        PushBufferStream[] pbss = pbds.getStreams();

        rtpMgrs = new RTPManager[pbss.length];
        SessionAddress localAddr, destAddr;
        InetAddress ipAddr;
        SendStream sendStream;
        audioReceiver = new AudioReceiver(this, jingleMediaSession);
        int port;

        for (int i = 0; i < pbss.length; i++) {
            try {
                rtpMgrs[i] = RTPManager.newInstance();

                port = portBase + 2 * i;
                ipAddr = InetAddress.getByName(remoteIpAddress);

                localAddr = new SessionAddress(InetAddress.getByName(this.localIpAddress),
                        localPort);

                destAddr = new SessionAddress(ipAddr, port);

                rtpMgrs[i].addReceiveStreamListener(audioReceiver);
                rtpMgrs[i].addSessionListener(audioReceiver);

                BufferControl bc = (BufferControl) rtpMgrs[i].getControl("javax.media.control.BufferControl");
                if (bc != null) {
                    int bl = 160;
                    bc.setBufferLength(bl);
                }

                try {

                    rtpMgrs[i].initialize(localAddr);

                }
                catch (InvalidSessionAddressException e) {
                    // In case the local address is not allowed to read, we user another local address
                    SessionAddress sessAddr = new SessionAddress();
                    localAddr = new SessionAddress(sessAddr.getDataAddress(),
                            localPort);
                    rtpMgrs[i].initialize(localAddr);
                }

                rtpMgrs[i].addTarget(destAddr);

                LOGGER.severe("Created RTP session at " + localPort + " to: " + remoteIpAddress + " " + port);

                sendStream = rtpMgrs[i].createSendStream(dataOutput, i);

                sendStreams.add(sendStream);

                sendStream.start();

            }
            catch (Exception e) {
                LOGGER.log(Level.WARNING, "exception", e);
                return e.getMessage();
            }
        }

        return null;
    }
752070
def ip_in_ipmask(ip, ipmask):
    '''
    
    '''
    mask_ip, mask = str_to_ipmask(ipmask)
    return ip_in_ip_mask(ip, mask_ip, mask)
737856
static <W, R> TcpClientImpl<W, R> _create(ClientState<W, R> state,
                                                                      TcpClientEventPublisher eventPublisher) {
        DetachedChannelPipeline channelPipeline = state.unsafeDetachedPipeline();
        state = state.channelProviderFactory(new TcpChannelProviderFactory(channelPipeline,
                                                                           state.getChannelProviderFactory()));

        HostConnectorFactory<W, R> hostConnectorFactory = new HostConnectorFactory<>(state, eventPublisher);

        ConnectionProvider<W, R> cp = state.getFactory()
                                             .newProvider(state.getHostStream().map(hostConnectorFactory));

        InterceptingTcpClient<W, R> interceptingTcpClient = new InterceptingTcpClientImpl<>(cp, eventPublisher);
        TcpClientImpl<W, R> client = new TcpClientImpl<>(state, eventPublisher, interceptingTcpClient);
        client.requestSetLazily = new ConnectionRequestImpl<>(cp);
        return client;
    }
424020
def make_cidr(gw, mask):
    
    try:
        int_mask = (0xFFFFFFFF << (32 - int(mask))) & 0xFFFFFFFF
        gw_addr_int = struct.unpack('>L', socket.inet_aton(gw))[0] & int_mask
        return (socket.inet_ntoa(struct.pack("!I", gw_addr_int)) +
                '/' + str(mask))
    except (socket.error, struct.error, ValueError, TypeError):
        return
36999
def _ipc_send(self, sock, message_type, payload):
        '''
        
        '''
        sock.sendall(self._pack(message_type, payload))
        data, msg_type = self._ipc_recv(sock)
        return data