==================== Problem Description ====================
A service port was created in activity through New ServerSocket (9090), why is the port not open when viewed through the netstat command?
And then at the client anyway also connected not on that sure
Code:
Server=new ServerSocket (12345);
System.out.println ("IP:" +server.getlocalsocketaddress () + "----Port:" +server.getlocalport ());
SYSTEM.OUT.PRINTLN ("Server IP:" +server.getinetaddress ());
SYSTEM.OUT.PRINTLN ("Server Build Success ************");
In the LOGCAT can see "Server build Success" and so on all the output, all normal, but there is no real open port
However, if you create the ServerSocket object directly in the application program, you can open the port and the client connection is normal.
Ask for advice!!!
Note:
Network permissions in manifest have been added.
<uses-permission
Android:name= "Android.permission.INTERNET" ></uses-permission>
<uses-permission
Android:name= "Android.permission.ACCESS_NETWORK_STATE" ></uses-permission>
==================== Solution 1====================
The port on the emulator is not a port on the PC, and the two need to be mapped
Map the native port tcp/6100 to the emulator tcp/7100 port (UDP is the same).
>adb–s emulator-5554 forward tcp:6100 tcp:7100
Creating port Problems with ServerSocket in Android