/** * @param socket * @param format * @param detectedTransportFactory * @return */ protected TcpTransport createTransport(Socket socket, WireFormat format, TcpTransportFactory detectedTransportFactory, InitBuffer initBuffer) throws IOException { return new TcpTransport(format, socket, initBuffer); }
@Override public int read() throws IOException { receiveCounter++; return super.read(); } @Override
protected void doRun() throws IOException { try { Object command = readCommand(); doConsume(command); } catch (SocketTimeoutException e) { } catch (InterruptedIOException e) { } }
protected TransportInfo configureTransport(final TcpTransportServer server, final Socket socket) throws Exception { WireFormat format = wireFormatFactory.createWireFormat(); Transport transport = createTransport(socket, format); return new TransportInfo(format, transport, transportFactory); }
/** * Allows subclasses of TcpTransportFactory to create custom instances of * TcpTransportServer. * * @param location * @param serverSocketFactory * @return a new TcpTransportServer instance. * @throws IOException * @throws URISyntaxException */ protected TcpTransportServer createTcpTransportServer(final URI location, ServerSocketFactory serverSocketFactory) throws IOException, URISyntaxException { return new TcpTransportServer(this, location, serverSocketFactory); }
@Override protected void fill() throws IOException { receiveCounter++; super.fill(); } };
@Override public SslTransport createTransport(WireFormat wireFormat, Socket socket, InitBuffer initBuffer) throws IOException { return new SslTransport(wireFormat, (SSLSocket)socket, initBuffer); } }
@Override public long skip(long n) throws IOException { receiveCounter++; return super.skip(n); } @Override
/** * Get the Response * * @return the Response or null if it is closed */ public Response getResponse() { return getResponse(0); }
public void setDiffServ(String diffServ) throws IllegalArgumentException { this.trafficClass = QualityOfServiceUtils.getDSCP(diffServ); this.diffServChosen = true; }
public void setTypeOfService(int typeOfService) { this.trafficClass = QualityOfServiceUtils.getToS(typeOfService); this.typeOfServiceChosen = true; }
public TcpTransport(WireFormat wireFormat, Socket socket, InitBuffer initBuffer) throws IOException { this.wireFormat = wireFormat; this.socket = socket; this.remoteLocation = null; this.localLocation = null; this.initBuffer = initBuffer; setDaemon(true); }
/** * write a byte on to the stream * * @param b - byte to write * @throws IOException */ public void write(int b) throws IOException { if ((bufferlen - count) < 1) { flush(); } buffer[count++] = (byte)b; }
/** * @return pretty print of this */ @Override public String toString() { return "" + getBindLocation(); }
/** * Allows subclasses of SslTransportFactory to create custom instances of * SslTransportServer. * * @param location * @param serverSocketFactory * @return a new SslTransportServer initialized from the given location and socket factory. * @throws IOException * @throws URISyntaxException */ protected SslTransportServer createSslTransportServer(final URI location, SSLServerSocketFactory serverSocketFactory) throws IOException, URISyntaxException { return new SslTransportServer(this, location, serverSocketFactory); }
protected void handleSocket(Socket socket) { doHandleSocket(socket); }
/** * Allow derived classes to override the Transport implementation that this transport server creates. * * @param socket * @param format * * @return a new Transport instance. * * @throws IOException */ protected Transport createTransport(Socket socket, WireFormat format) throws IOException { return new TcpTransport(format, socket); }
@Override public int read(byte[] b, int off, int len) throws IOException { receiveCounter++; return super.read(b, off, len); } @Override
@Override public int read() throws IOException { if (position >= count) { fill(); if (position >= count) { return -1; } } return internalBuffer[position++] & 0xff; }
/** * Used to create Transports for this server. * * Overridden to allow the use of SslTransports (instead of TcpTransports). * * @param socket The incoming socket that will be wrapped into the new Transport. * @param format The WireFormat being used. * @return The newly return (SSL) Transport. * @throws IOException */ @Override protected Transport createTransport(Socket socket, WireFormat format) throws IOException { return new SslTransport(format, (SSLSocket)socket); }