你好,所以我只是想知道。我正在为我的游戏创建多人游戏,如果我想发送一些东西,我应该使用:
dos = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
dos.writeUTF(username);
dos = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
dos.writeUTF("test");
dis = new DataInputStream(new BufferedInputStream(socket.getInputStream()));
String loginResponse = dis.readUTF();
或者我应该使用:
dos = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
dos.writeUTF(username);
dos.writeUTF("test");
dis = new DataInputStream(new BufferedInputStream(socket.getInputStream()));
String loginResponse = dis.readUTF();