Issue
Why does the android emulator connect to a socket server running on my PC but not receive any messages that are send back down the same line?
The android app connects to my C# socket server on 192.168.1.33 port 2012 successfully and messages can go from the android to the server no problem. Using the same socket connection I send a message down the socket to the android - but no message received on the android side.
I've tried various combinations of listening/connecting IP addresses (10.0.2.2, 10.0.2.15) as advised elsewhere and for some reason connecting to 127.0.0.1 doesn't even seem to allow connection to my C# socket server at all.
I've attempted port forwarding on the android using:
Telnet o localhost 5554
redir add tcp:2012:2012
so that the port 2012 on my PC maps to the port 2012 on the emulator itself, but this doesn't fix the problem.
The info on which is the correct IP address and port to use (along with the port forwarding stuff) is confusing...does anyone understand how to get this working?
Note: messages send back and forth between my C# client and server apps without a problem. It only doesn't work correctly with the android acting as the client
Solution
The solution was nothing to do with the connection or ports. The problem was with the data that I was sending back to the android device.
A newline character is required for the socket to flush the information to the device:
socket.Send(message + "\n");
Answered By - Shane
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.