I’ve copy/pasted the code from this tutorial about sockets on Android.
It builds fine and runs as expected, until a connection is attempted.
I’ve got it connected with USB and I’ve used ADB to turn on port forwarding.
I’ve written test apps in C# (which I’m more comfortable with than Java) and I keep getting error 10061:
No connection could be made because the target computer actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host—that is, one with no server application running.
When I use SocketTest, I get the following (rather cryptic) message:
Connection error: connect
I’ve tried disabling my firewall, but this doesn’t help. What could be wrong?
It turns out it was to do with ADB. I had started port forwarding at the beginning of my session, but the ADB process must have restarted at some point because when I reissued the port forward command my app sprang to life.
Real pity there’s no way of viewing the ports currently being forwarded by ADB. I suppose the bottom line is “if in doubt, do it again”.