SockeTcp01Client.java
package org.example.socket;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
public class SocketTcp01Client {
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();
byte[] content = "HelloServer,This is a message come from Client".getBytes();
outputStream.write(content);
outputStream.close();
socket.close();
}
}