私は、クライアントがボタンclick.Iでテキストをサーバーに送ることができるアプリケーションを作成していますが、クライアント側のボタンが押されるたびに何も起こりません。サーバーはクライアントのJavaからテキストを受け取ることができません
そして時々私はコンソールのこの行を得ました[email protected]
。 これはなぜ起こっているのですか?
サーバコード:
public static ServerSocket server = null;
public static Socket client = null;
public static void main(String []arg)throws IOException{
try {
server = new ServerSocket(8002);
System.out.println("Server Started...............");
while(true){
client = server.accept();
DataInputStream in = new DataInputStream(client.getInputStream());
String msg = in.readLine();
System.out.println("and: "+msg);
}
}catch(IOException r){
System.out.println("error :"+r.getMessage());
}
}
クライアントコード:
public void send(){
send.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
Socket cs = null;
try {
cs = new Socket("192.168.1.100", 8002);
DataOutputStream out = new DataOutputStream(cs.getOutputStream());
out.writeBytes(text.toString());
} catch (IOException e) {
Toast.makeText(KeyboardActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
}
}
}
);
}
うん、それは... !!!私はそのような騒ぎです:( –