/** @see com.thinkparity.network.NetworkConnection#connect() */
 @Override
 public void connect() throws NetworkException {
   logger.logTraceId();
   logger.logInfo("{0} - Connect.", getId());
   Exception lastX = null;
   connected = false;
   for (final NetworkProxy proxy : proxies) {
     this.proxy = proxy;
     try {
       connectViaProxy();
       setSocketOptions();
       setSocketStreams();
       logger.logInfo("{0} - Connected.", getId());
       logger.logDebug(
           "{0} - Local:  {1}:{2}",
           getId(), socket.getLocalAddress().getHostAddress(), socket.getLocalPort());
       final InetSocketAddress remoteSocketAddress =
           (InetSocketAddress) socket.getRemoteSocketAddress();
       logger.logDebug(
           "{0} - Remote:  {1}:{2}",
           getId(),
           remoteSocketAddress.getAddress().getHostAddress(),
           remoteSocketAddress.getPort());
       connected = true;
       break;
     } catch (final SocketException sx) {
       lastX = sx;
     } catch (final IOException iox) {
       lastX = iox;
     }
   }
   if (false == connected) {
     throw new NetworkException(lastX);
   }
 }
Esempio n. 2
0
 /** Stop the stream service. */
 public void stop() {
   logger.logTraceId();
   logger.logInfo("Stopping stream service.");
   synchronized (this) {
     stopImpl();
   }
   logger.logInfo("Stream service stopped.");
 }
Esempio n. 3
0
 /** Start the stream service. */
 public void start() {
   logger.logTraceId();
   logger.logInfo("Starting stream service.");
   synchronized (this) {
     startImpl();
   }
   logger.logInfo("Stream service started.");
 }
Esempio n. 4
0
 /** Stop stream service implementation. */
 private void stopImpl() {
   logger.logTraceId();
   try {
     server.stop(Boolean.TRUE);
   } catch (final Throwable t) {
     throw new StreamException(t);
   } finally {
     server = null;
   }
 }
 /** @see com.thinkparity.network.NetworkConnection#write(byte[]) */
 @Override
 public void write(final byte[] buffer) throws NetworkException {
   logger.logTraceId();
   logger.logVariable("buffer", buffer);
   ensureConnected();
   try {
     write(buffer, true);
   } catch (final IOException iox) {
     throw new NetworkException(iox);
   }
 }
 /** @see com.thinkparity.network.NetworkConnection#read(byte[]) */
 @Override
 public int read(final byte[] buffer) throws NetworkException {
   logger.logTraceId();
   logger.logVariable("buffer", buffer);
   ensureConnected();
   try {
     return input.read(buffer);
   } catch (final IOException iox) {
     throw new NetworkException(iox);
   }
 }
Esempio n. 7
0
 /** Start stream service implementation. */
 private void startImpl() {
   logger.logTraceId();
   try {
     server =
         new StreamServer(
             new File(properties.getProperty(JivePropertyNames.THINKPARITY_STREAM_ROOT)),
             environment);
     server.start();
   } catch (final Throwable t) {
     server = null;
     throw new StreamException(t);
   }
 }
 /** @see com.thinkparity.network.NetworkConnection#disconnect() */
 @Override
 public void disconnect() {
   logger.logTraceId();
   logger.logInfo("{0} - Disconnect", getId());
   if (isConnected()) {
     try {
       if (Boolean.FALSE == protocol.isSecure()) {
         socket.shutdownInput();
       }
     } catch (final IOException iox) {
       logger.logWarning(iox, "{0} - Error disconnecting.", getId());
     } finally {
       try {
         if (Boolean.FALSE == protocol.isSecure()) {
           socket.shutdownOutput();
         }
       } catch (final IOException iox) {
         logger.logWarning(iox, "{0} - Error disconnecting.", getId());
       } finally {
         try {
           socket.close();
         } catch (final IOException iox) {
           logger.logWarning(iox, "{0} - Error disconnecting.", getId());
         } finally {
           socket = null;
           input = null;
           output = null;
           logger.logInfo("{0} - Disconnected", getId());
           connected = false;
         }
       }
     }
   } else {
     logger.logWarning("{0} - Is not connected.", getId());
   }
 }
 /**
  * Obtain the proxy.
  *
  * @return A <code>NetworkProxy</code>.
  */
 NetworkProxy getProxy() {
   logger.logTraceId();
   return proxy;
 }
 /**
  * Obtain the protocol.
  *
  * @return A <code>NetworkProtocol</code>.
  */
 NetworkProtocol getProtocol() {
   logger.logTraceId();
   return protocol;
 }
 /** @see com.thinkparity.network.NetworkConnection#isConnected() */
 @Override
 public Boolean isConnected() {
   logger.logTraceId();
   return connected && socket.isConnected();
 }
 /** @see com.thinkparity.network.NetworkConnection#getSocket() */
 @Override
 public Socket getSocket() {
   logger.logTraceId();
   return socket;
 }
 /** @see com.thinkparity.network.NetworkConnection#getId() */
 @Override
 public String getId() {
   logger.logTraceId();
   return id;
 }
 /** @see com.thinkparity.network.NetworkConnection#getAddress() */
 public NetworkAddress getAddress() {
   logger.logTraceId();
   return address;
 }