问题描述:
使用TCP发送多个文件,每发完一个文件就关闭Socket,断开连接。发送下一个文件时在建立连接。建立连接代码如下:
@Override
public void run() {
Log.i(TAG, "TcpFileReceiver被创建");
while (true) {
try {
serverSocket = new ServerSocket(9999); // 指定播放软件监听端口
socket = serverSocket.accept();
if (socket != null) {
Log.i(TAG, "Socket连接建立in");
bufferedInputStream = new BufferedInputStream(socket.getInputStream());
bufferedOutputStream = new BufferedOutputStream(socket.getOutputStream());
// 开启线程接收上位机发送的数据包
isReceiveFileThreadRun = true;
receiveFileThread = new ReceiveFileThread();
receiveFileThread.start();
Log.i(TAG, "Socket连接建立out");
} else {
Log.i(TAG, &#