create a forwarder device
357318
function forwarder(frontPort, backPort) {
  var frontSocket = zeromq.socket('sub'),
      backSocket = zeromq.socket('pub');

  frontSocket.identity = 'sub' + process.pid;
  backSocket.identity = 'pub' + process.pid;

  frontSocket.subscribe('');
  frontSocket.bind(frontPort, function (err) {
    console.log('bound', frontPort);
  });
    
  var totalMessages=0;
  frontSocket.on('message', function() {
    //pass to back
    //console.log('forwarder: recasting', arguments[0].toString());
    backSocket.send(Array.prototype.slice.call(arguments));
    totalMessages++;
  });

  backSocket.bind(backPort, function (err) {
    console.log('bound', backPort);
  });

  // lets count messages forwarded
  setInterval(function() {
    console.log('messages forwarded = ' + totalMessages);
    totalMessages=0;
  }, 1000);

}
483049
public void forwardBroadcast (Name from, byte levelOrMode, String bundle, String msg)
    {
        for (PeerNode peer : _peers.values()) {
            if (peer.nodeobj != null) {
                ((CrowdNodeObject)peer.nodeobj).crowdPeerService.deliverBroadcast(
                    from, levelOrMode, bundle, msg);
            }
        }
    }
896994
def create_router(self, context, router):
        """"""

        # Add router to the DB
        new_router = super(AristaL3ServicePlugin, self).create_router(
            context,
            router)
        # create router on the Arista Hw
        try:
            self.driver.create_router(context, new_router)
            return new_router
        except Exception:
            with excutils.save_and_reraise_exception():
                LOG.error(_LE("Error creating router on Arista HW router=%s "),
                          new_router)
                super(AristaL3ServicePlugin, self).delete_router(
                    context,
                    new_router['id']
                )
1134641
def create(self, destination, mask, next_hops=[]):
        """"""
        payload = {
            "rib": self._build_payload(destination, mask, next_hops)
        }

        return self._post(self.url_prefix, payload)
479999
def add_router_to_hosting_device(self, client, hosting_device_id, body):
        """"""
        res_path = hostingdevice.HostingDevice.resource_path
        return client.post((res_path + DEVICE_L3_ROUTERS) %
                           hosting_device_id, body=body)
213025
def forward(self):
        
        if not self.object_id or self.__is_draft:
            raise RuntimeError("Can't forward this message")

        url = self.build_url(
            self._endpoints.get('forward_message').format(id=self.object_id))

        response = self.con.post(url)
        if not response:
            return None

        message = response.json()

        # Everything received from cloud must be passed as self._cloud_data_key
        return self.__class__(parent=self, **{self._cloud_data_key: message})
634624
def main(http_port, peer_name, node_name, app_id):
    
    # Create the framework
    framework = pelix.framework.create_framework(
        ('pelix.ipopo.core',
         'pelix.ipopo.waiting',
         'pelix.shell.core',
         'pelix.shell.ipopo',
         'pelix.shell.console',
         'pelix.http.basic',

         # Herald core
         'herald.core',
         'herald.directory',
         'herald.shell',

         # Herald HTTP
         'herald.transports.http.directory',
         'herald.transports.http.discovery_multicast',
         'herald.transports.http.servlet',
         'herald.transports.http.transport',

         # RPC
         'pelix.remote.dispatcher',
         'pelix.remote.registry',
         'herald.remote.discovery',
         'herald.remote.herald_xmlrpc',),
        {herald.FWPROP_NODE_UID: node_name,
         herald.FWPROP_NODE_NAME: node_name,
         herald.FWPROP_PEER_NAME: peer_name,
         herald.FWPROP_APPLICATION_ID: app_id})

    # Start everything
    framework.start()
    context = framework.get_bundle_context()

    # Instantiate components
    with use_waiting_list(context) as ipopo:
        # ... HTTP server
        ipopo.add(pelix.http.FACTORY_HTTP_BASIC, "http-server",
                  {pelix.http.HTTP_SERVICE_PORT: http_port})

        # ... HTTP reception servlet
        ipopo.add(herald.transports.http.FACTORY_SERVLET,
                  "herald-http-servlet")

        # ... HTTP multicast discovery
        ipopo.add(herald.transports.http.FACTORY_DISCOVERY_MULTICAST,
                  "herald-http-discovery-multicast")

    # Start the framework and wait for it to stop
    framework.wait_for_stop()
1025140
def create_ports(port, mpi, rank):
        """"""
        if port == "random" or port is None:
            # ports will be filled in using random binding
            ports = {}
        else:
            port = int(port)
            ports = {
                "REQ": port + 0,
                "PUSH": port + 1,
                "SUB": port + 2
            }
        # if we want to communicate with separate domains
        # we have to setup a socket for each of them
        if mpi == 'all':
            # use a socket for each rank rank
            for port in ports:
                ports[port] += (rank * 3)
        return ports
595475
def push(item, remote_addr, trg_queue, protocol=u'jsonrpc'):
    '''  '''
    if protocol == u'jsonrpc':
        try:
            server = Server(remote_addr, encoding=_c.FSQ_CHARSET)
            return server.enqueue(item.id, trg_queue, item.item.read())
        except Exception, e:
            raise FSQPushError(e)

    raise ValueError('Unknown protocol: {0}'.format(protocol))
1226930
def create_deliveryserver(self, domainid, data):
        """"""
        return self.api_call(
            ENDPOINTS['deliveryservers']['new'],
            dict(domainid=domainid),
            body=data)
1207795
def create_device(device_args):
    
    device = AlarmDecoder(USBDevice.find(device_args))
    device.on_message += handle_message
    device.open()

    return device
315289
def create_uinput_device(mapping):
    """"""
    if mapping not in _mappings:
        raise DeviceError("Unknown device mapping: {0}".format(mapping))

    try:
        mapping = _mappings[mapping]
        device = UInputDevice(mapping)
    except UInputError as err:
        raise DeviceError(err)

    return device
624609
def make_connection(self, transport, address):
        """"""
        self.connected = True
        self.transport = transport
        self.connection_made(address)
1350630
def add_device(self, path):
        ""
        if self.__get_control_socket():
            self.sock.sendall("+%s\r\n\x00" % path)
            self.sock.recv(12)
            self.sock.close()
1206342
def list_port_forwarding_rules(ip_address_id=nil, listall=false)
      params = { 'command' => 'listPortForwardingRules' }
      params['ipAddressId'] = ip_address_id if ip_address_id
      params['listall'] = listall
      json = send_request(params)
      json['portforwardingrule']
    end
1366781
def send(self, cmd, timeout, wait_for_string, password):
        """"""
        return self.target_device.send(cmd, timeout=timeout, wait_for_string=wait_for_string, password=password)
1041425
def create_remote(self, name, url, **kwargs):
        """"""
        return Remote.create(self, name, url, **kwargs)