完整的代码
追答Scanner input = new Scanner(System.in);
Socket socket = new Socket("localhost",6000);
ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
//自己创建一个消息对象Message里面根据自己需求封装信息
Message msg = new Message();
out.writeObject(msg);