我在我的设备中实现了一个带有服务器套接字的线程,它显示来自(例如)浏览器的传入连接。我已经正确找到IP
了客户端的地址,但我无法找到 url 参数。你能给我帮助吗?请考虑这个字符串,例如:192.168.1.110:80/?id=123
或者192.168.1.110/page?id=123
这是我的班级。
public class ServerThread implements Runnable {
public void run(){
try{
if ( SERVERIP != null){
serverStatus.setText("Listening on IP: " + ip_address_conversion + ":" + SERVERPORT);
serverSocket = new ServerSocket(SERVERPORT);
while (true){
Socket client = serverSocket.accept();
handler.post(new Runnable(){
@Override
public void run(){
serverStatus.setText("Connected");
}
});
InetAddress ip_client = client.getInetAddress();
Log.i("Log", "ip client "+ip_client);
//Here i have to find the url params
}
}
} catch (Exception e){
serverStatus.setText("Error");
}
}
}
谢谢