Examples of Socket


Examples of cli.System.Net.Sockets.Socket

    private int processFDSet(long updateCount, ArrayList sockets, int rOps)
    {
        int numKeysUpdated = 0;
        for (int i = 0; i < sockets.get_Count(); i++)
        {
            Socket desc = (Socket)sockets.get_Item(i);
            if (desc == wakeupSourceFd)
            {
                synchronized (interruptLock)
                {
                    interruptTriggered = true;
View Full Code Here

Examples of com.github.nkzawa.socketio.client.Socket

    if ((!this.orderFeed.isEmpty() || this.subscribeAccountInfo) && (this.accessKey == null || this.secretKey == null)) {
      throw new IllegalArgumentException("Access key and secret key are required to subscribe order feed and account info.");
    }

    final Socket socket;
    try {
      socket = IO.socket(uri, opt);
    } catch (URISyntaxException e) {
      throw new IllegalArgumentException(e);
    }

    socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {

      @Override
      public void call(Object... args) {

        subscribeMarketData();
        subscribeGrouporder();
        subscribePrivateData();
      }

      private void subscribeMarketData() {

        subscribe("marketdata", marketData);
      }

      private void subscribeGrouporder() {

        subscribe("grouporder", grouporder);
      }

      private void subscribe(String name, Iterable<CurrencyPair> currencyPairs) {

        for (CurrencyPair currencyPair : currencyPairs) {
          String market = toMarket(currencyPair);
          String subscribeData = String.format("%s_%s", name, market);
          log.debug("subscribing {}", subscribeData);
          socket.emit("subscribe", subscribeData);
        }
      }

      private void subscribePrivateData() {

        final List<String> params = buildPrivateDataParams();

        if (!params.isEmpty()) {
          BTCChinaPayload payload = getPayload(params.toArray(new String[0]));

          final List<String> arg = new ArrayList<String>(2);
          arg.add(toPostData(payload));
          arg.add(getSign(payload));

          // Use 'private' method to subscribe the order feed
          socket.emit("private", arg);
        } else {
          log.debug("No private data specified to subscribe.");
        }
      }
View Full Code Here

Examples of com.openmashupos.socket.client.Socket

     
        Button b = new Button("Send hello to 127.0.0.1:100");
      b.addClickListener(new ClickListener(){
      public void onClick(Widget sender)
      {
          final Socket socketToApp1 = new Socket("127.0.0.1",100);
         
          socketToApp1.setSocketCallback( new SocketCallback()
          {
            // data = "DOMLocation;proxy"
            public void onDataReceived(String data)
            {
              Debug.log(1, "hey I received: " + data);
            }
            public void onConnected()
            {
              Debug.log(1, "Connected to 127.0.0.1:100!");
              socketToApp1.send("Hello Mr. 127.0.0.1:100");
            }
            public void onDisconnected(String message)
            {
              Window.alert("Discunnected : "+ message );
            }
          });
      }
    });
     
    RootPanel.get().add(b);

      }

     if(RootPanel.get("type-mashup-app1") != null )
      {

           Button b = new Button("Make me bigger!");
         b.addClickListener(new ClickListener(){
         public void onClick(Widget sender)
         {
           setSize("100%", "50%");
         }
         });
         RootPanel.get().add(b);
        
        ServerSocket ss = new ServerSocket(100);
       
        ss.accept(new ServerSocketCallback()
        {
          public void onConnectionAccepted(final Socket s)
          {
            s.setSocketCallback(new SocketCallback()
            {
              public void onDisconnected(String msg)
              {
              }
             
              // request: "domain name" response "DOMAddress;proxyURL"
              public void onDataReceived(String data)
              {
                // for now, assume it is ProxyDNSEntry
                //Window.alert("Mashup App1 received data :"+data);
                Debug.log(1,"Received data ( "+data+")"+ " from " +s.getEndpointDomainName());
                s.send("Echoing :"+ data);
              }
              // TODO does not get called for server side
              public void onConnected()
              {

              }
            }
            );

          }
          public void onError(String s)
          {
           
          }
        }
        );

      }
    
     if(RootPanel.get("type-mashup-app2") != null )
     {
          Button b = new Button("Send hello to 127.0.0.1:100");
          RootPanel.get().add(b);
         b.addClickListener(new ClickListener(){
         public void onClick(Widget sender)
         {
             final Socket socketToApp1 = new Socket("127.0.0.1",100);
              socketToApp1.setSocketCallback( new SocketCallback()
             {
               // data = "DOMLocation;proxy"
               public void onDataReceived(String data)
               {
                 Debug.log(1, "Hey I received: " + data);
                 socketToApp1.close();
               }
               public void onConnected()
               {
                 Debug.log(1, "Connected to 127.0.0.1:100!");
                 socketToApp1.send("Hello Mr. 127.0.0.1:100");
               }

               public void onDisconnected(String message)
               {
                 Window.alert("Discunnected : "+ message );
View Full Code Here

Examples of com.sun.midp.io.j2me.serversocket.Socket

        ServerSocketConnection serv;

        initialize(MIDletSuiteUtils.getIsolateId());

        try {
            Socket s = new Socket();
            s.open(PORT, token);
            serv = (ServerSocketConnection) s;
        } catch (Throwable t) {
            d("failed " + t.toString());
            t.printStackTrace();
            return;
View Full Code Here

Examples of fbench.graph.Socket

        if (adplist.getLength() < 1)
            return;
        NodeList adps = ((Element) adplist.item(0)).getChildNodes();
        for (int i = 0; i < adps.getLength(); i++) {
            GraphElement ge = adptype.equals("Plugs") ? new Plug()
                    : new Socket();
            ge.setElement((Element) adps.item(i));
            if (ge != null)
                graph.add(ge);
        }
    }
View Full Code Here

Examples of java.net.Socket

    private void connectToStateProvider(StateHeader hdr) {
        IpAddress address = hdr.bind_addr;
        String tmp_state_id = hdr.getStateId();
        InputStream bis = null;
        StateTransferInfo sti = null;
        Socket socket = new Socket();
        try {
            socket.bind(new InetSocketAddress(bind_addr, 0));
            int bufferSize = socket.getReceiveBufferSize();
            socket.setReceiveBufferSize(socket_buffer_size);
            if (log.isDebugEnabled())
                log.debug("Connecting to state provider " + address.getIpAddress() + ":"
                        + address.getPort() + ", original buffer size was " + bufferSize
                        + " and was reset to " + socket.getReceiveBufferSize());
           
            Util.connect(socket, new InetSocketAddress(address.getIpAddress(), address.getPort()), 0);
            if (log.isDebugEnabled())
                log.debug("Connected to state provider, my end of the socket is "
                        + socket.getLocalAddress() + ":" + socket.getLocalPort()
                        + " passing inputstream up...");

            // write out our state_id and address
            ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
            out.writeObject(tmp_state_id);
            out.writeObject(local_addr);

            bis = new BufferedInputStream(new StreamingInputStreamWrapper(socket),socket_buffer_size);
            sti = new StateTransferInfo(hdr.sender, bis, tmp_state_id);
            up_prot.up(new Event(Event.STATE_TRANSFER_INPUTSTREAM, sti));
        } catch (IOException e) {
            if (log.isWarnEnabled()) {
                log.warn("State reader socket thread spawned abnormaly", e);
            }

            // pass null stream up so that JChannel.getState() returns false
            InputStream is = null;
            sti = new StateTransferInfo(hdr.sender, is, tmp_state_id);
            up_prot.up(new Event(Event.STATE_TRANSFER_INPUTSTREAM, sti));
        } finally {
            if (!socket.isConnected()) {
                if (log.isWarnEnabled())
                    log.warn("Could not connect to state provider. Closing socket...");
            }
            Util.close(bis);
            Util.close(socket);
View Full Code Here

Examples of java.net.Socket

                try {
                    if (log.isDebugEnabled())
                        log.debug("StateProviderThreadSpawner listening at "
                                + getServerSocketAddress() + "...");

                    final Socket socket = serverSocket.accept();
                    pool.execute(new Runnable() {
                        public void run() {
                            if (log.isDebugEnabled())
                                log.debug("Accepted request for state transfer from "
                                        + socket.getInetAddress() + ":" + socket.getPort()
                                        + " handing of to PooledExecutor thread");
                            new StateProviderHandler().process(socket);
                        }
                    });
View Full Code Here

Examples of java.net.Socket

    // Create a new socket thread, and start it running
    SocketThread st = new SocketThread( addr, port );
    st.start();
   
    int timer = 0;
    Socket sock = null;
   
    for (;;) {
      // Check to see if a connection is established
     
      if (st.isConnected()) {
View Full Code Here

Examples of java.net.Socket

      m_port = port;
    }
   
    public void run() {
      // Socket used for establishing a connection
      Socket sock = null;
     
      try {
  // Was a string or an inet specified
  if (m_host != null) {
    // Connect to a remote host - BLOCKING I/O
    sock = new Socket (m_host, m_port);
  } else {
    // Connect to a remote host - BLOCKING I/O
    sock = new Socket (m_inet, m_port);
  }
      }
      catch (IOException ioe) {
  // Assign to our exception member variable
  m_exception = ioe;
View Full Code Here

Examples of java.net.Socket

     
      socket = (SSLSocket)factory.createSocket(host,port);

    } else {
     
      Socket tunnel = new Socket(proxyHost, proxyPort);
      doTunnelHandshake(tunnel, host, port);
     
      /*
       * Ok, let's overlay the tunnel socket with SSL.
       */
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.