Examples of VirtualSocket


Examples of org.jboss.remoting.transport.multiplex.VirtualSocket

      // Get client invoker's MultiplexingManager.
      MultiplexClientInvoker clientInvoker = (MultiplexClientInvoker) client.getInvoker();
      field = MultiplexClientInvoker.class.getDeclaredField("socketGroupInfo");
      field.setAccessible(true);
      SocketGroupInfo sgi = (SocketGroupInfo) field.get(clientInvoker);
      VirtualSocket socket = sgi.getPrimingSocket();
      field = VirtualSocket.class.getDeclaredField("manager");
      field.setAccessible(true);
      MultiplexingManager clientManager = (MultiplexingManager) field.get(socket);
      assertNotNull(clientManager);
     
View Full Code Here

Examples of org.jboss.remoting.transport.multiplex.VirtualSocket

   {
      SocketFactory sf = getSocketFactory();
      if (sf == null)
         createSocketFactory(configuration);

      VirtualSocket socket = new VirtualSocket(configuration);
      socket.connect(getConnectSocketAddress(), getBindSocketAddress(), this.timeout);
      return socket;
   }
View Full Code Here

Examples of org.jboss.remoting.transport.multiplex.VirtualSocket

                  case CONNECT_TO_CLIENT:

                     try
                     {
                        socketToClient = new VirtualSocket(clientServerSocketHost, socket.getPort());
                        is_client = socketToClient.getInputStream();
                        os_client = socketToClient.getOutputStream();
                     }
                     catch(IOException e)
                     {
                        log.error("unable to create VirtualSocket back to client", e);
                        socketToClient = null;
                     }

                     break;

                  case CONNECT_TO_CLIENT_VSS:

                     socketToClient = null;
                     nextRemotePort++;

                     // Since we're reusing ports, the ServerSocket might not be available yet.
                     for(int j = 0; j < 5; j++)
                     {
                        try
                        {
                           log.info("connecting to (" + clientServerSocketHost + ", " + nextRemotePort + ")");
                           socketToClient = new VirtualSocket(clientServerSocketHost, nextRemotePort);
                           is_client = socketToClient.getInputStream();
                           os_client = socketToClient.getOutputStream();
                           break;
                        }
                        catch(IOException e)
                        {
                           log.error("unable to create VirtualSocket back to client: trying again", e);
                           Thread.sleep(1000);
                        }
                     }

                     if(socketToClient == null)
                     {
                        log.error("giving up attempt to create VirtualSocket back to client");
                     }

                     break;


                  case CONNECT_TO_CLIENT_MSS:

                     socketToClient = null;
                     nextRemotePort++;
                     log.info("connecting to (" + clientServerSocketHost + ", " + nextRemotePort + ")");

                     // Since we're reusing ports, the ServerSocket might not be available yet.
                     for(int j = 0; j < 5; j++)
                     {
                        try
                        {
                           socketToClient = new VirtualSocket(clientServerSocketHost, nextRemotePort);
                           is_client = socketToClient.getInputStream();
                           os_client = socketToClient.getOutputStream();
                           break;
                        }
                        catch(IOException e)
                        {
                           log.info("unable to create VirtualSocket back to client: trying again", e);
                           Thread.sleep(1000);
                        }
                     }

                     if(socketToClient == null)
                     {
                        log.error("giving up attempt to create VirtualSocket back to client");
                     }

                     break;

                  case READ_FROM_CLIENT:

                     if(socketToClient == null)
                     {
                        log.error("unable to read from client: socket has not been opened");
                     }
                     else
                     {
                        b = is_client.read();
                     }

                     break;

                  case WRITE_TO_CLIENT:

                     if(socketToClient == null)
                     {
                        log.error("unable to write to client: socket has not been opened");
                     }
                     else
                     {
                        os_client.write(i);
                     }

                     break;

                  case CLOSE_CLIENT_SOCKET:

                     if(socketToClient == null)
                     {
                        log.error("unable to close socket to client: not open");
                     }
                     else
                     {
                        socketToClient.close();
                        socketToClient = null;
                     }

                     break;

                  case RUN_VIRTUALSERVERSOCKET:

                     mss = new MasterServerSocket(basicBehaviorServerPort + 1);
                     os.write(3);
                     Socket virtualSocket1 = mss.accept();
                     Socket virtualSocket2 = mss.accept();
                     int localPort = virtualSocket2.getLocalPort();
                     log.info("VirtualServerSocket binding to port: " + localPort);
                     vss = new VirtualServerSocket(localPort);
                     os.write(5);
                     Socket virtualSocket3 = vss.accept();
                     DataOutputStream vos = new DataOutputStream(virtualSocket3.getOutputStream());
                     vos.writeInt(localPort);
                     virtualSocket1.close();
                     virtualSocket2.close();
                     virtualSocket3.close();
                     mss.close();
                     vss.close();
                     break;

                  case RUN_SERVER_TIMEOUT_TEST:
                     Socket virtualSocket4 = null;
                     Socket virtualSocket5 = null;
                     Socket virtualSocket6 = null;
                     Socket virtualSocket7 = null;

                     mss = new MasterServerSocket(basicBehaviorServerPort + 100);
                     mss.setSoTimeout(10000);
                     os.write(3);
                     Thread.sleep(1000);

                     try
                     {
                        virtualSocket4 = mss.accept();
                        log.info("accepted virtualSocket4");
                     }
                     catch(SocketTimeoutException e)
                     {
                        log.info(e);
                     }

                     try
                     {
                        virtualSocket5 = mss.accept();
                        log.info("accepted virtualSocket5");
                     }
                     catch(SocketTimeoutException e)
                     {
                        log.info("timed out waiting to accept virtualSocket5");
                     }

                     is.read();
                     Thread.sleep(1000);
                     vss = new VirtualServerSocket(basicBehaviorServerPort + 101);
                     SocketAddress address1 = new InetSocketAddress(clientServerSocketHost, clientServerSocketPort + 101);
                     vss.connect(address1);
                     os.write(5);
                     Thread.sleep(1000);
                     vss.setSoTimeout(10000);

                     try
                     {
                        virtualSocket6 = vss.accept();
                        log.info("accepted virtualSocket6");
                     }
                     catch(SocketTimeoutException e)
                     {
                        log.info(e);
                     }

                     try
                     {
                        virtualSocket7 = vss.accept();
                        log.info("accepted virtualSocket7");
                     }
                     catch(SocketTimeoutException e)
                     {
                        log.info(e);
                     }

                     if(virtualSocket4 != null)
                     {
                        virtualSocket4.close();
                     }
                     if(virtualSocket5 != null)
                     {
                        virtualSocket5.close();
                     }
                     if(virtualSocket6 != null)
                     {
                        virtualSocket6.close();
                     }
                     if(virtualSocket7 != null)
                     {
                        virtualSocket7.close();
                     }
                     mss.close();
                     vss.close();
                     break;

                  case RUN_VSS_TO_VSS:
                     mss = new MasterServerSocket(++nextBindPort);
                     log.info("MasterServerSocket accepting connections on: " + nextBindPort);
                     os.write(3);
//                     int port = mss.acceptServerSocketConnection().getSocket().getLocalPort();
                     int port = mss.acceptServerSocketConnection();
                     vss = new VirtualServerSocket(port);
                     InetSocketAddress address = new InetSocketAddress(clientServerSocketHost, ++nextRemotePort);
                     is.read();
                     log.info("VirtualServerSocket connecting to port: " + nextRemotePort);
                     vss.connect(address);
                     log.info("VirtualServerSocket accepting connections on: " + nextBindPort);
                     os.write(7);
                     Socket virtualSocket8 = vss.accept();
                     log.info("first virtual socket created");
                     InputStream is8 = virtualSocket8.getInputStream();
                     OutputStream os8 = virtualSocket8.getOutputStream();
                     log.info("second virtual socket connecting to port: " + nextRemotePort);
                     Socket virtualSocket9 = new VirtualSocket(clientServerSocketHost, nextRemotePort);
                     log.info("second virtual socket created");
                     InputStream is9 = virtualSocket9.getInputStream();
                     OutputStream os9 = virtualSocket9.getOutputStream();
                     os8.write(is8.read());
                     os9.write(is9.read());
                     virtualSocket8.close();
                     virtualSocket9.close();
                     vss.close();
                     mss.close();
                     break;
                    
                  case RUN_LONG_MESSAGE_TEST:
View Full Code Here

Examples of org.jboss.remoting.transport.multiplex.VirtualSocket

   {
      log.info("Starting client test");

      try
      {
         socket = new VirtualSocket("127.0.0.1", 1999);
      }
      catch(UnknownHostException e)
      {
         log.error("UnknownHostException for \"localhost\"");
         e.printStackTrace();
View Full Code Here

Examples of org.jboss.remoting.transport.multiplex.VirtualSocket

      log.info("entering setUp() for test: " + testName);
      Exception savedException = null;

      if(scriptSocket == null)
      {
         scriptSocket = new VirtualSocket();
         InetSocketAddress address = new InetSocketAddress(basicBehaviorServerHost, basicBehaviorServerPort);

         for(int i = 0; i < 5; i++)
         {
            try
            {
               scriptSocket.connect(address, 5000);
               break;
            }
            catch(IOException e)
            {
               log.info("unable to connect script socket: trying again");
               savedException = e;

               try
               {
                  Thread.sleep(1000);
               }
               catch(InterruptedException ignored)
               {
               }
            }
         }

         if(scriptSocket == null)
         {
            log.error(savedException);
            savedException.printStackTrace();
            throw savedException;
         }

         scriptStream = scriptSocket.getOutputStream();
         log.info("BasicBehaviorClient: got message socket and message OutputStream");

         String pattern = "%5p [%t] (%F:%L) <%d{ABSOLUTE}> - %m%n";
         PatternLayout layout = new PatternLayout(pattern);

         try
         {
            File logFile = new File("test_logs");
            logFile.mkdir();
            FileAppender fileAppender = new FileAppender(layout, "test_logs" + File.separator + "basic.output.log");
            fileAppender.setAppend(false);
            //fileAppender.setThreshold(Level.toLevel(testLogLevel));
            Category.getRoot().addAppender(fileAppender);
         }
         catch(IOException e)
         {
            e.printStackTrace();
         }
      }

      testSocket = new VirtualSocket(basicBehaviorServerHost, basicBehaviorServerPort);

      log.info("BasicBehaviorClient: got test socket: " +
               ((VirtualSocket)testSocket).getLocalSocketId().getPort());

      if(random == null)
View Full Code Here

Examples of org.jboss.remoting.transport.multiplex.VirtualSocket

         Socket virtualSocket1 = vss.accept();
         InputStream is1 = virtualSocket1.getInputStream();
         OutputStream os1 = virtualSocket1.getOutputStream();
        
         // Create a virtual socket connected to the remote VirtualServerSocket.
         Socket virtualSocket2 = new VirtualSocket(connectHost, connectPort);
         InputStream is2 = virtualSocket2.getInputStream();
         OutputStream os2 = virtualSocket2.getOutputStream();
        
         // Do some i/o and close sockets.
         os1.write(is1.read());
         os2.write(is2.read());
         virtualSocket1.close();
         virtualSocket2.close();
         syncSocket.close();
         vss.close();
      }
      catch (Exception e)
      {
View Full Code Here

Examples of org.jboss.remoting.transport.multiplex.VirtualSocket

            Thread.sleep(2000);
           
            // connect to VirtualServerSocket
            String hostName = virtualSocket.getInetAddress().getHostName();
            int port = virtualSocket.getPort();
            Socket v3 = new VirtualSocket(hostName, port);
           
            // send an object to the client
            ObjectOutputStream oos = new ObjectOutputStream(v3.getOutputStream());
            oos.writeObject(new Integer(7));
           
            oos.flush();
            v3.close();
         }
         catch (Exception e)
         {
            e.printStackTrace();
            System.exit(1);
View Full Code Here

Examples of org.jboss.remoting.transport.multiplex.VirtualSocket

   {
      SocketFactory sf = getSocketFactory();
      if (sf == null)
         createSocketFactory(configuration);

      VirtualSocket socket = new VirtualSocket(configuration);
      socket.connect(getConnectSocketAddress(), getBindSocketAddress(), this.timeout);
      return socket;
   }
View Full Code Here

Examples of org.jboss.remoting.transport.multiplex.VirtualSocket

         // Call constructor to create a virtual socket and connect it to the port on the server
         // to which the VirtualServerSocket is connected.
         os_sync.write(5);
         is_sync.read();
         int port = serverSocket.getRemotePort();
         Socket virtualSocket1 = new VirtualSocket(connectHost, port);
         InputStream is1 = virtualSocket1.getInputStream();
         OutputStream os1 = virtualSocket1.getOutputStream();
        
         // Create a virtual socket by way of VirtualServerSocket.accept().
         Socket virtualSocket2 = serverSocket.accept();
         InputStream is2 = virtualSocket2.getInputStream();
         OutputStream os2 = virtualSocket2.getOutputStream();
        
         // Do some i/o and close sockets.
         os1.write(9);
         System.out.println(is1.read());
         os2.write(11);
         System.out.println(is2.read());
         virtualSocket1.close();
         virtualSocket2.close();
         syncSocket.close();
         serverSocket.close();
      }
      catch (Exception e)
View Full Code Here

Examples of org.jboss.remoting.transport.multiplex.VirtualSocket

   public void runPrimeScenario()
   {
      try
      {
         // create a VirtualSocket and connect it to MasterServerSocket
         Socket v1 = new VirtualSocket("localhost", 5555);
        
         // do some asynchronous input in a separate thread
         new AsynchronousThread(v1).start();
        
         // do some synchronous communication
         ObjectOutputStream oos = new ObjectOutputStream(v1.getOutputStream());
         ObjectInputStream ois = new ObjectInputStream(v1.getInputStream());
         oos.writeObject(new Integer(3));
         Integer i1 = (Integer) ois.readObject();
         System.out.println("synch: " + i1);
         v1.close();
      }
      catch (Exception e)
      {
         e.printStackTrace();
         System.exit(1);
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.