|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jpl.mipl.mdms.connection.SocketStream
public class SocketStream
This is a wrapper class to the java socket class. It addes additional useful methods to simplify sending and receiving of data stream.
Constructor Summary | |
---|---|
SocketStream()
Default constructor to initialize the socket stream object. |
|
SocketStream(Socket s)
Constructor to initialize the socket stream object with a Socket object. |
Method Summary | |
---|---|
void |
close()
Closes the socket connection, if it exists. |
protected void |
finalize()
Cleanup method execute by the garbage collector. |
DataInputStream |
getDataInputStream()
Access method to the internal data input stream object. |
DataOutputStream |
getDataOutputStream()
Access method to the internal output data stream object. |
Socket |
getSocket()
To return the internal socket object. |
int |
recv()
Reads an int from a socket |
int |
recv(StringBuffer sb)
Receives a string buffer from the socket. |
int |
recvNBytes(byte[] b,
int offset,
int n)
Receives an array of bytes. |
int |
send(int val)
Sends an int through the socket. |
int |
send(String s)
Sends a string through the socket. |
int |
send(StringBuffer sb)
Sends a String Buffer through the socket. |
int |
sendNBytes(byte[] b,
int offset,
int length)
Sends an array of bytes through the socket. |
void |
setDataInputStream(InputStream is)
Sets the internal input data stream object. |
void |
setDataOutputStream(OutputStream os)
Sets the internal data output stream. |
void |
setSocket(Socket s)
Sets the socket object and initializes the internal I/O stream objects. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SocketStream()
public SocketStream(Socket s) throws IOException
s
- The socket object.
IOException
- when I/O failureMethod Detail |
---|
public void setSocket(Socket s) throws IOException
s
- The socket object.
IOException
- when I/O failurepublic Socket getSocket()
public void close() throws IOException
IOException
- when I/O failurepublic int send(StringBuffer sb) throws IOException
sb
- The input string buffer.
IOException
- when I/O failurepublic int send(String s) throws IOException
s
- The input string to be sent.
IOException
- when I/O failurepublic int send(int val) throws IOException
val
- the integer value
IOException
- when I/O failurepublic int sendNBytes(byte[] b, int offset, int length) throws IOException
b
- The input byte array.offset
- The input offset.length
- The length of the byte array.
IOException
- when I/O failurepublic int recv(StringBuffer sb) throws IOException
sb
- The output string buffer.
IOException
- when I/O failurepublic int recv() throws IOException
IOException
- when I/O failurepublic int recvNBytes(byte[] b, int offset, int n) throws IOException
b
- The received byte array.offset
- The returned offset value.n
- The number of bytes received.
IOException
- when I/O failurepublic void setDataOutputStream(OutputStream os)
os
- The input output stream object.public DataOutputStream getDataOutputStream()
public void setDataInputStream(InputStream is)
is
- The input stream object.public DataInputStream getDataInputStream()
protected void finalize() throws Throwable
finalize
in class Object
Throwable
- when finalizing
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |