- The Server and Client are connected on the same local network.
- The port info is easy for both server and client to know.
- Only Client and server are present on the local network. (not necessary but does make configuring easier)
NOTE: I have only tested this code with an Android Phone and a Linux Computer as server and client (and vice-versa) respectively.
- Use Phone Hotspot and connect computer to it. (Making them both on the same local network)
- Use USB Debugging on Phone and connect phone to Computer.
- Write your go code for client and server.
- The ip address to use can be found using ip address of Phone or Computer (use ip of whichever device you are using as server).
4.1. To get ip address of both phone and computer. Write
ifconfig
on computer to get computer's ip 4.2. To get phone's ip addr usearp -a
to get phone's ip address. (Assuming no other device is connected to the mobile hotspot). 4.3 Use a port between 1025 and 60000. These are all unpriviledged ports and hence shoudnt cause problems in using. - Use
GOARCH=arm64 GOOS=linux go build -o logproxyservice main.go
to compile the golang code which needs to go to the Android Phone. - Use
adb devices
in terminal to see if the phone is connected via USB to computer or not. [This will only work if USB Debugging is turned ON in the Android phone] - Use
adb push <<NAME_OF_BINARY_GENERATED_BY_GOLANG>> /data/local/tmp/
to push the binary to the Android Phone. - Use
adb shell
to open remote shell of Android Phone on Computer. - In shell write commands
cd /data/local/tmp/
thenls
then./<<NAME_OF_BINARY_GENERATED_BY_GOLANG>>
- In Computer side run the other script (Server/Client) by using command
go run .
[Do this in a DIFFERENT terminal]