0
私は、ソケットを使用してWiFi経由でPCにデータを送信するJ2MEアプリケーションに取り組んでいます。サーバーのアドレスはどのようにする必要がありますか?つまり、以下のコードで 'localhost'の代わりに何を使用すればよいですか?j2me-j2seソケット接続
クライアントコード(J2ME):
SocketConnection sc = (SocketConnection)
Connector.open("socket://localhost:9002");
DataOutputStream os = null;
try{
os = sc.openDataOutputStream();
os.writeUTF("Test Dama");
} finally{
sc.close();
os.close();
}
Serverコード(J2SE):
ServerSocket echoServer = null;
String line;
DataInputStream is;
Socket clientSocket = null;
try {
echoServer = new ServerSocket(9002);
}
catch (IOException e) {
System.out.println(e);
}
try {
clientSocket = echoServer.accept();
is = new DataInputStream(clientSocket.getInputStream());
line = is.readUTF();
System.out.println("Received:"+line);
}
catch (IOException e) {
System.out.println(e);
}
ありがとうございます。 –