public class TcpReceive extends Object implements AutoCloseable
Constructor and Description |
---|
TcpReceive(int port) |
Modifier and Type | Method and Description |
---|---|
TcpReceive |
accept(int count)
接收几个连接
|
TcpReceive |
acceptThreadPool(ExecutorService acceptThreadPool) |
TcpReceive |
bufferSize(int bufferSize) |
void |
close() |
TcpReceive |
closePool()
关闭线程池
|
List<Socket> |
findSocket(String host)
寻找客户端 socket
|
Socket |
findSocket(String host,
int port)
寻找客户端 socket
|
int |
getPort() |
List<Socket> |
getReceiveSocketList() |
ServerSocket |
getServerSocket() |
TcpReceive |
sendAll(byte b) |
TcpReceive |
sendAll(byte[] bs)
批量发送数据
|
TcpReceive |
sendAll(byte[] bs,
int off,
int len)
批量发送数据
|
TcpReceive |
timeout(int timeOut) |
public TcpReceive(int port) throws IOException
IOException
public TcpReceive bufferSize(int bufferSize) throws SocketException
SocketException
public TcpReceive timeout(int timeOut) throws SocketException
SocketException
public TcpReceive acceptThreadPool(ExecutorService acceptThreadPool)
public TcpReceive accept(int count)
count
- countpublic TcpReceive sendAll(byte b) throws IOException
IOException
public TcpReceive sendAll(byte[] bs) throws IOException
bs
- bsIOException
- IOExceptionpublic TcpReceive sendAll(byte[] bs, int off, int len) throws IOException
bs
- bytesoff
- offsetlen
- lengthIOException
- IOExceptionpublic Socket findSocket(String host, int port)
host
- hostport
- portpublic List<Socket> findSocket(String host)
host
- hostpublic TcpReceive closePool()
public void close()
close
in interface AutoCloseable
public int getPort()
public ServerSocket getServerSocket()
Copyright © 2024. All rights reserved.