我是套接字编程的新手。
我希望与特定的IP连接(例如:184.267.345.65)& Android中的端口(例如:53)所以怎么可能呢?
提前致谢。
答案 0 :(得分:4)
答案 1 :(得分:-2)
URLConnection connection = null;
URL url = null;
InputStream is = null;
String mUrl="IP ADDRESS AND PORT NUMBER";
try {
url = new URL(mUrl);
connection = url.openConnection();
connection.setRequestProperty("Accept", "SPECIFY ACCEPT TYPE");
is = connection.getInputStream();
String data=convertStreamToString(is);
} catch (Exception e) {
Log.i("Exception while reading inputstream From URL :"+mUrl, e.getMessage());
e.printStackTrace();
}