01.socket定义
02.TCP编程
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
public class clientSocket {
public static void main(String[] args) throws IOException {
Socket socket= new Socket(InetAddress.getLocalHost(),9999);
System.out.println("客户端的socket"+socket.getClass());
OutputStream outputStream= socket.getOutputStream();
outputStream.write("hello ".getBytes());
outputStream.close();
socket.close();
}
}
在这里插入代码片