public class SocketPipe extends Object implements Pipe
SocketPipe
represents pipe that can transfer data from one socket to
another socket. The tow socket should be connected sockets. If any of the them occurred error the
pipe will close all of them.Modifier and Type | Field and Description |
---|---|
protected static org.slf4j.Logger |
logger
Logger
|
Constructor and Description |
---|
SocketPipe(Socket socket1,
Socket socket2)
Constructs SocketPipe instance by tow connected sockets.
|
Modifier and Type | Method and Description |
---|---|
void |
addPipeListener(PipeListener pipeListener)
Adds pipe listener.
|
boolean |
close()
Close pipe.
|
int |
getBufferSize()
GEts the buffer size.
|
String |
getName()
Returns pipe's name.
|
boolean |
isRunning()
If the pipe is running.
|
void |
removePipeListener(PipeListener pipeListener)
Removes pipe listener.
|
void |
setBufferSize(int bufferSize)
Sets buffer size.
|
void |
setName(String name)
Sets pipe's name.
|
boolean |
start()
Start the pipe, the pipe will work with a new thread.
|
boolean |
stop()
Stop the pipe, the pipe will stop transferring data.
|
public SocketPipe(Socket socket1, Socket socket2) throws IOException
socket1
- A connected socket.socket2
- Another connected socket.IOException
- If an I/O error occurred.public boolean start()
Pipe
public boolean stop()
Pipe
public boolean close()
Pipe
public int getBufferSize()
Pipe
getBufferSize
in interface Pipe
public void setBufferSize(int bufferSize)
Pipe
setBufferSize
in interface Pipe
bufferSize
- Buffer size.public boolean isRunning()
Pipe
public void addPipeListener(PipeListener pipeListener)
Pipe
addPipeListener
in interface Pipe
pipeListener
- Pipe listener.public void removePipeListener(PipeListener pipeListener)
Pipe
removePipeListener
in interface Pipe
pipeListener
- Pipe listener.Copyright © 2015. All rights reserved.