Socket Communication Between Android And Windows
Is it possible to Android Emulator will be socket server and Windows form app will be client and they communicate each other? My emulator IP address is 192.168.232.2 but i cannot p
Solution 1:
When creating a ServerSocket in your Android code, you can assign a port to it by passing it, for example here I'm opening a ServerSocket
on the port 8080:
val serverSocket = ServerSocket(8080)
You then need to use adb
to forward incoming connection to your emulator, by running, here forwarding the port 8080 again
adb forward tcp:8080 tcp:8080
At this point any connection to your PC on port 8080 will be forwarded to your emulator.
You can get the IP by typing in the terminal ifconfig
or ipconfig
depending on your operating system.
The easiest way to test it is to run both client and server on your PC and just use localhost
or 127.0.0.1
as the IP address.
Post a Comment for "Socket Communication Between Android And Windows"