Why not call accept with no timeout?

 socket = mmServerSocket.accept();

That makes more sense.


On Thursday, February 7, 2013 11:13:21 AM UTC-6, tom_mai78101 wrote:
>
> There is an attachment that contains an Android application project for 
> Eclipse, zipped nicely in a ZIP folder.
>  
> *Problem:* I'm having this issue of getting "Connection Refused" after I 
> initiated a pairing between two Android devices. While waiting to accept 
> incoming connections, I gave it a timeout value of 12000, which I believed 
> it to be 12 seconds long. Below is the Logcat output:
>  
>
>> D/DEBUG(24298): Connect Thread is now running.
>> D/DEBUG(24298): Connect Thread is now accepting.
>> D/DEBUG(24298): Unable to create a socket for targetSocket.
>> D/DEBUG(24298): java.io.IOException: Connection refused
>> D/DEBUG(24298):  at 
>> android.bluetooth.BluetoothSocket.connectNative(Native Method)
>> D/DEBUG(24298):  at 
>> android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:212)
>> D/DEBUG(24298):  at o.p.Main$1.onReceive(Main.java:138)
>> D/DEBUG(24298):  at 
>> android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:781)
>> D/DEBUG(24298):  at android.os.Handler.handleCallback(Handler.java:605)
>> D/DEBUG(24298):  at android.os.Handler.dispatchMessage(Handler.java:92)
>> D/DEBUG(24298):  at android.os.Looper.loop(Looper.java:154)
>> D/DEBUG(24298):  at 
>> android.app.ActivityThread.main(ActivityThread.java:4945)
>> D/DEBUG(24298):  at java.lang.reflect.Method.invokeNative(Native Method)
>> D/DEBUG(24298):  at java.lang.reflect.Method.invoke(Method.java:511)
>> D/DEBUG(24298):  at 
>> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
>> D/DEBUG(24298):  at 
>> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
>> D/DEBUG(24298):  at dalvik.system.NativeStart.main(Native Method)
>> D/DEBUG(24298): Unable to accept incoming connection.
>> D/DEBUG(24298): java.io.IOException: Connection timed out
>> D/DEBUG(24298):  at android.bluetooth.BluetoothSocket.acceptNative(Native 
>> Method)
>> D/DEBUG(24298):  at 
>> android.bluetooth.BluetoothSocket.accept(BluetoothSocket.java:311)
>> D/DEBUG(24298):  at 
>> android.bluetooth.BluetoothServerSocket.accept(BluetoothServerSocket.java:107)
>> D/DEBUG(24298):  at o.p.Main$Connect.run(Main.java:62)
>> D/DEBUG(24298):  at 
>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
>> D/DEBUG(24298):  at 
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
>> D/DEBUG(24298):  at java.lang.Thread.run(Thread.java:864)
>> D/DEBUG(24298): Now closing the targetServerSocket.
>>
> I would like for someone to help me on getting two devices to connect 
> successfully. If for some reason, this "Connection Refused" is very common, 
> what known steps can I take that I have not covered? Thanks in advance.
>  
> *Hardware (Android OS Version):* HTC Evo 3D (4.0.3), Samsung Galaxy Nexus 
> (4.1.1)
>  
> *Have covered:* 
>
>    1. Using 1 randomly-generated UUID for the entire execution of the app.
>    2. Using 2 randomly-generated UUID for the entire execution of the 
>    app. One UUID is for BluetoothDevice.createRf...(), the other is for 
>    BluetoothServerSocket.listen...().
>    3. Using the workaround invocation method (Method invoking) of 
>    "removeBond", "createBond", and "createRfcommSocket".
>
>  
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to