0

on my Android Phonne, I checked my Ip address is 10.0.0.8 so, I assign a socket to my phone

   Socket socket = new Socket("10.0.0.8",3200);

my server IP is 10.0.0.6

so I try alternative,

    Socket socket = new Socket("10.0.0.6",3200);

same error, connection refused.

But when I stepped into the line, it says Connection refused. I mean, why connection refused? It's itself , no need to make a connection. All I am doing is to make a socket and there's no connection yet.

On my computer I ping both 10.0.0.6 and 10.0.0.8 and successful. Peer to Peer network is enabled.

1 Answer 1

1

When you run this code, it attempts to connect to the server on a port which may or may not be accepting incoming connections.

This can be seen from the android development references:

Socket(InetAddress dstAddress, int dstPort) Creates a new streaming socket connected to the target host specified by the parameters dstAddress and dstPort. -http://developer.android.com/reference/java/net/Socket.html

For examples of how to use Sockets in your Android program, I suggest looking at this site: http://thinkandroid.wordpress.com/2010/03/27/incorporating-socket-programming-into-your-applications/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.