TCP(Transmission Control Protocol 传输控制协议)是一种面向连接的、可靠的、基于字节流的传输层通信协议。
*服务端不断接收来自客户端的请求*Server.java
package com.example.tang.tcp;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
public class Server {
ServerSocket ss;
public Server() {
try {
ss=new ServerSocket(9999);//创建ServerSocket对象,端口9999
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
new myThrea