如何使用Android中的Socket连接到服务器

时间:2013-06-17 11:38:19

标签: java android sockets

我希望我的Android手机能够连接到我的其他服务器。我不知道如何向服务器发送请求以获得响应。

这是我的代码

try
{
Socket connfd = new Socket("192.168.1.100", 5000 );
InputStream in = connfd.getInputStream();
OutputStream out = connfd.getOutputStream();
BufferedReader con = new BufferedReader(new InputStreamReader(System.in));
}catch(IOException e1){
    e1.printStackTrace();

}

1 个答案:

答案 0 :(得分:1)

Here你可以找到一个样本。 我希望它有所帮助:)