1

Why can't a socket be open with this code:

                try {
                    Connect=(Button)findViewById(R.id.connect);
                    InetSocketAddress address = new InetSocketAddress("192.168.1.2",54628);
                    DatagramPacket request = new DatagramPacket(cmd.getBytes(), cmd.length(), address);
                    DatagramSocket socket = new DatagramSocket();
                    socket.send(request);
                } catch (SocketException e) {
                    System.out.print("SSSS");
                }

but it does work when I do:

    clientSocket= new Socket("192.168.1.2",54635); 
    Text.append( "\n created a socket");

Error logs:

05-24 23:04:58.497: ERROR/AudioPolicyManagerBase(95): unknown stream type
05-24 23:05:10.787: ERROR/AudioPolicyManagerBase(95): unknown stream type
05-24 23:05:10.787: ERROR/AudioPolicyManagerBase(95): unknown stream type
05-24 23:05:10.787: ERROR/AudioPolicyManagerBase(95): unknown stream type
05-24 23:05:10.787: ERROR/AudioPolicyManagerBase(95): unknown stream type
3
  • 1
    maybe because the port is different? Commented May 24, 2011 at 20:48
  • 3
    You asked 13 question and didn't accept just one of them. And you think someone is going to help you on this? Commented May 24, 2011 at 20:50
  • @ Mighuel no the same port is to the servers Commented May 24, 2011 at 21:06

1 Answer 1

1

You should really consider going back over your other questions and accepting answers if they worked for you. You are less likely to get help with 0% accept rate.

Change your System.out.print() statement to e.printStackTrace(); Then run the app and copy the output from your Logcat and paste it in your question. That will help us understand what is actually going wrong.

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.