Tabnine Logo
TSocket
Code IndexAdd Tabnine to your IDE (free)

How to use
TSocket
in
libthrift091.transport

Best Java code snippets using libthrift091.transport.TSocket (Showing top 13 results out of 315)

origin: com.xiaomi.infra.galaxy/galaxy-thrift-api

/**
 * Returns a reference to the underlying socket.
 */
public Socket getSocket() {
 if (socket_ == null) {
  initSocket();
 }
 return socket_;
}
origin: XiaoMi/galaxy-sdk-java

protected TSocket acceptImpl() throws TTransportException {
 if (serverSocket_ == null) {
  throw new TTransportException(TTransportException.NOT_OPEN, "No underlying server socket.");
 }
 try {
  Socket result = serverSocket_.accept();
  TSocket result2 = new TSocket(result);
  result2.setTimeout(clientTimeout_);
  return result2;
 } catch (IOException iox) {
  throw new TTransportException(iox);
 }
}
origin: com.xiaomi.infra.galaxy/galaxy-thrift-api

/**
 * Connects the socket, creating a new socket object if necessary.
 */
public void open() throws TTransportException {
 if (isOpen()) {
  throw new TTransportException(TTransportException.ALREADY_OPEN, "Socket already connected.");
 }
 if (host_.length() == 0) {
  throw new TTransportException(TTransportException.NOT_OPEN, "Cannot open null host.");
 }
 if (port_ <= 0) {
  throw new TTransportException(TTransportException.NOT_OPEN, "Cannot open without port.");
 }
 if (socket_ == null) {
  initSocket();
 }
 try {
  socket_.connect(new InetSocketAddress(host_, port_), timeout_);
  inputStream_ = new BufferedInputStream(socket_.getInputStream(), 1024);
  outputStream_ = new BufferedOutputStream(socket_.getOutputStream(), 1024);
 } catch (IOException iox) {
  close();
  throw new TTransportException(TTransportException.NOT_OPEN, iox);
 }
}
origin: com.xiaomi.infra.galaxy/galaxy-thrift-api

private static TSocket createClient(SSLSocketFactory factory, String host, int port, int timeout) throws TTransportException {
 try {
  SSLSocket socket = (SSLSocket) factory.createSocket(host, port);
  socket.setSoTimeout(timeout);
  return new TSocket(socket);
 } catch (Exception e) {
  throw new TTransportException("Could not connect to " + host + " on port " + port, e);
 }
}
origin: XiaoMi/galaxy-sdk-java

/**
 * Constructor that takes an already created socket.
 *
 * @param socket Already created socket object
 * @throws TTransportException if there is an error setting up the streams
 */
public TSocket(Socket socket) throws TTransportException {
 socket_ = socket;
 try {
  socket_.setSoLinger(false, 0);
  socket_.setTcpNoDelay(true);
 } catch (SocketException sx) {
  LOGGER.warn("Could not configure socket.", sx);
 }
 if (isOpen()) {
  try {
   inputStream_ = new BufferedInputStream(socket_.getInputStream(), 1024);
   outputStream_ = new BufferedOutputStream(socket_.getOutputStream(), 1024);
  } catch (IOException iox) {
   close();
   throw new TTransportException(TTransportException.NOT_OPEN, iox);
  }
 }
}
origin: com.xiaomi.infra.galaxy/galaxy-thrift-api

protected TSocket acceptImpl() throws TTransportException {
 if (serverSocket_ == null) {
  throw new TTransportException(TTransportException.NOT_OPEN, "No underlying server socket.");
 }
 try {
  Socket result = serverSocket_.accept();
  TSocket result2 = new TSocket(result);
  result2.setTimeout(clientTimeout_);
  return result2;
 } catch (IOException iox) {
  throw new TTransportException(iox);
 }
}
origin: XiaoMi/galaxy-sdk-java

/**
 * Connects the socket, creating a new socket object if necessary.
 */
public void open() throws TTransportException {
 if (isOpen()) {
  throw new TTransportException(TTransportException.ALREADY_OPEN, "Socket already connected.");
 }
 if (host_.length() == 0) {
  throw new TTransportException(TTransportException.NOT_OPEN, "Cannot open null host.");
 }
 if (port_ <= 0) {
  throw new TTransportException(TTransportException.NOT_OPEN, "Cannot open without port.");
 }
 if (socket_ == null) {
  initSocket();
 }
 try {
  socket_.connect(new InetSocketAddress(host_, port_), timeout_);
  inputStream_ = new BufferedInputStream(socket_.getInputStream(), 1024);
  outputStream_ = new BufferedOutputStream(socket_.getOutputStream(), 1024);
 } catch (IOException iox) {
  close();
  throw new TTransportException(TTransportException.NOT_OPEN, iox);
 }
}
origin: XiaoMi/galaxy-sdk-java

private static TSocket createClient(SSLSocketFactory factory, String host, int port, int timeout) throws TTransportException {
 try {
  SSLSocket socket = (SSLSocket) factory.createSocket(host, port);
  socket.setSoTimeout(timeout);
  return new TSocket(socket);
 } catch (Exception e) {
  throw new TTransportException("Could not connect to " + host + " on port " + port, e);
 }
}
origin: com.xiaomi.infra.galaxy/galaxy-thrift-api

/**
 * Constructor that takes an already created socket.
 *
 * @param socket Already created socket object
 * @throws TTransportException if there is an error setting up the streams
 */
public TSocket(Socket socket) throws TTransportException {
 socket_ = socket;
 try {
  socket_.setSoLinger(false, 0);
  socket_.setTcpNoDelay(true);
 } catch (SocketException sx) {
  LOGGER.warn("Could not configure socket.", sx);
 }
 if (isOpen()) {
  try {
   inputStream_ = new BufferedInputStream(socket_.getInputStream(), 1024);
   outputStream_ = new BufferedOutputStream(socket_.getOutputStream(), 1024);
  } catch (IOException iox) {
   close();
   throw new TTransportException(TTransportException.NOT_OPEN, iox);
  }
 }
}
origin: com.xiaomi.infra.galaxy/galaxy-lcs-log-core

 private LCSThriftService.Client createLCSThriftClient() {
  TSocket socket = new TSocket(
    lcsAgentHostname, lcsAgentPort, 4096 * 512);
  TTransport transport = new TFramedTransport(socket);
  try {
   transport.open();
  } catch (TTransportException e) {
   logger.info("Failed to create client for LCSAgent: " + lcsAgentHostname +
     ":" + lcsAgentPort, e);
   return null;
  }
  TProtocol protocol = new TCompactProtocol(transport);
  return new LCSThriftService.Client(protocol);
 }
}
origin: XiaoMi/galaxy-sdk-java

/**
 * Returns a reference to the underlying socket.
 */
public Socket getSocket() {
 if (socket_ == null) {
  initSocket();
 }
 return socket_;
}
origin: com.xiaomi.infra.galaxy/galaxy-thrift-api

/**
 * Creates a new unconnected socket that will connect to the given host
 * on the given port.
 *
 * @param host    Remote host
 * @param port    Remote port
 * @param timeout Socket timeout
 */
public TSocket(String host, int port, int timeout) {
 host_ = host;
 port_ = port;
 timeout_ = timeout;
 initSocket();
}
origin: XiaoMi/galaxy-sdk-java

/**
 * Creates a new unconnected socket that will connect to the given host
 * on the given port.
 *
 * @param host    Remote host
 * @param port    Remote port
 * @param timeout Socket timeout
 */
public TSocket(String host, int port, int timeout) {
 host_ = host;
 port_ = port;
 timeout_ = timeout;
 initSocket();
}
libthrift091.transportTSocket

Javadoc

Socket implementation of the TTransport interface. To be commented soon!

Most used methods

  • <init>
    Constructor that takes an already created socket.
  • close
    Closes the socket.
  • initSocket
    Initializes the socket object
  • isOpen
    Checks whether the socket is connected.
  • setTimeout
    Sets the socket timeout

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getContentResolver (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getResourceAsStream (ClassLoader)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now