I’m attempting to connect to a TCP socket in Android.
I know the socket service works because I can connect and interact with it in a browser (in JavaScript) as follows:
var ws = window.WebSocket || window.MozWebSocket;
window.ws = new wsImpl('ws://foo.bar.com:8282/MySocketService', 'my-protocol');
...
So, in my Android app:
This connects successfully, but I never receive messages from it:
SocketAddress sa = new InetSocketAddress("foo.bar.com", 8282);
This fails to connect:
SocketAddress sa = new InetSocketAddress("foo.bar.com/MySocketService", 8282);
and I receive an error like:
java.net.UnknownHostException: Host is unresolved: foo.bar.com/MySocketService:8282
Is there any way to indicate the application path for a TCP service?
TCP end-point is just IP address and a port number. What you are talking about is handled by upper-level protocols on top of TCP, like HTTP, so you need to look at other utilities like
java.net.URL.