com.epam.common.transport
Class SocketTransport

java.lang.Object
  extended by com.epam.common.transport.SocketTransport
All Implemented Interfaces:
Transport
Direct Known Subclasses:
TCPTransport

public abstract class SocketTransport
extends Object
implements Transport

Abstract socket implementation of transport.


Field Summary
protected  InputStream is
           
protected  OutputStream os
           
protected  Socket socket
           
 
Constructor Summary
SocketTransport()
           
 
Method Summary
 void close()
          Close the transport.
 String getAddress()
          Getter for address value.
 InputStream getInputStream()
           
 OutputStream getOutputStream()
          Gets output stream.
 int getPort()
          Getter for port value.
 boolean isBlockingSocket()
           
 boolean isOpen()
          Returns true if, transport is open.
abstract  void open()
          Open the transport.
 int read(byte[] buffer)
          Transport dependent read method.
 int read(byte[] buffer, int offset, int length)
          Transport dependent read method.
 int read(ByteBuffer buffer)
           
 int read(ByteBuffer buffer, int offset, int length)
           
 void waitUntilReadyToWrite()
           
 void write(byte[] message)
          Transport dependent write method.
 int write(byte[] message, int offset, int length)
          Transport dependent write method.
 int write(ByteBuffer buffer)
           
 int write(ByteBuffer buffer, int offset, int length)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

socket

protected Socket socket

is

protected InputStream is

os

protected OutputStream os
Constructor Detail

SocketTransport

public SocketTransport()
Method Detail

getInputStream

public InputStream getInputStream()

isBlockingSocket

public boolean isBlockingSocket()
Specified by:
isBlockingSocket in interface Transport

getOutputStream

public OutputStream getOutputStream()
Gets output stream.

Returns:
output stream

read

public int read(byte[] buffer,
                int offset,
                int length)
         throws IOException
Description copied from interface: Transport
Transport dependent read method.

Specified by:
read in interface Transport
Parameters:
buffer - holder for read bytes
offset - in buffer
length - maximum bytes to be read
Returns:
number of byte actually read
Throws:
IOException - if unable to read
See Also:
Transport.read(byte[], int, int)

read

public int read(byte[] buffer)
         throws IOException
Description copied from interface: Transport
Transport dependent read method.

Specified by:
read in interface Transport
Parameters:
buffer - holder for read bytes
Returns:
number of byte actually read
Throws:
IOException - if unable to read
See Also:
Transport.read(byte[])

write

public void write(byte[] message)
           throws IOException
Description copied from interface: Transport
Transport dependent write method.

Specified by:
write in interface Transport
Parameters:
message - actual message
Throws:
IOException - if unable to write
See Also:
Transport.write(byte[])

write

public int write(byte[] message,
                 int offset,
                 int length)
          throws IOException
Description copied from interface: Transport
Transport dependent write method.

Specified by:
write in interface Transport
Parameters:
message - actual message
offset - the offset in buffer
length - the num of bytes to write
Throws:
IOException - if unable to write

write

public int write(ByteBuffer buffer)
          throws IOException
Specified by:
write in interface Transport
Throws:
IOException

write

public int write(ByteBuffer buffer,
                 int offset,
                 int length)
          throws IOException
Specified by:
write in interface Transport
Throws:
IOException

read

public int read(ByteBuffer buffer,
                int offset,
                int length)
         throws IOException
Specified by:
read in interface Transport
Throws:
IOException

read

public int read(ByteBuffer buffer)
         throws IOException
Specified by:
read in interface Transport
Throws:
IOException

waitUntilReadyToWrite

public void waitUntilReadyToWrite()
                           throws IOException
Specified by:
waitUntilReadyToWrite in interface Transport
Throws:
IOException

getAddress

public String getAddress()
Description copied from interface: Transport
Getter for address value.

Specified by:
getAddress in interface Transport
See Also:
Transport.getAddress()

getPort

public int getPort()
Description copied from interface: Transport
Getter for port value.

Specified by:
getPort in interface Transport
See Also:
Transport.getPort()

close

public void close()
           throws IOException
Description copied from interface: Transport
Close the transport.

Specified by:
close in interface Transport
Throws:
IOException - - throws if error occurred
See Also:
Transport.close()

open

public abstract void open()
                   throws IOException
Description copied from interface: Transport
Open the transport.

Specified by:
open in interface Transport
Throws:
IOException - - throws if error occurred
See Also:
Transport.open()

isOpen

public boolean isOpen()
Description copied from interface: Transport
Returns true if, transport is open.

Specified by:
isOpen in interface Transport
See Also:
Transport.isOpen()


Copyright © 2000-2014 EPAM Systems. All Rights Reserved.