Java套接字在连接到服务器期间发送一些数据

我有一个小型服务器和客户端java程序。 它们通过套接字进行交互。

Java服务器非常简单。 它从套接字接收字符并在控制台中打印它。

import java.net.*; import java.io.*; import java.util.Date; public class DataServerSIMS { static final int LISTENING_PORT = 2002; public static void main(String[] args) { ServerSocket listener; //Checks the connection requests Socket connection; //To interact with other progs Reader incoming; //Stream try { listener = new ServerSocket(LISTENING_PORT); TextIO.putln("Listening on port "+LISTENING_PORT); while (true) { connection = listener.accept(); try { incoming = new InputStreamReader(connection.getInputStream()); while (true) { int ch = incoming.read(); if (ch == 1 || ch == '\r') break; System.out.print((char)ch); } System.out.println(); incoming.close(); } catch (IOException e) { TextIO.putln("Error: "+e); }//end try recieving data }//end while } catch (Exception e) { TextIO.putln("Sorry, the server has shut down."); TextIO.putln("Error: "+e); return; } } } 

客户端程序与服务器建立连接

 connectionToServer = new Socket (deviceServer, connectionPort); 

我根本不会从程序的任何一点发送任何数据。

deviceServer =“127.0.0.1”connectionPort = 2002

由于此操作的执行

 connectionToServer = new Socket (deviceServer, connectionPort); 

服务器接受连接并在char后打印这样的字符串char:

 Fdsfsdfs 

这个字符串是什么意思? 我怎样才能防止它发送到服务器?