Connector.open returns TCP error code 10053 (Socket shut down by application.)

151 views
Skip to first unread message

deanb...@gmail.com

unread,
Sep 2, 2007, 2:55:56 PM9/2/07
to bluecove-users
I had a previous thread about Connector.open() crashing the IBM J9
JVM. That problem is resolved and a bug filed. However, it led to a
new problem.

When I issue a Connector.open() I get a TCP error code of 10053
(Socket shut down by application). This does not happen with Avetana
so it should work. I am using Windows Mobile 5.0 running on a Samsung
BlackJack with IBM's J9 JVM v6.1.1 and the Microsoft Bluetooth stack.

>From what I gather online the 10053 error code can happen for a couple
of reasons:
1. close(socket) is called
2. socket is not actually the same integer returned by connect()

Looking at the BlueCove code I see
com.intel.bluetooth.BluetoothStackMicrosoft is used. It's
connectionRfOpenClientConnection method is called with
params.authenticate and params.encrypt both false:

public long
connectionRfOpenClientConnection(BluetoothConnectionParams params)
throws IOException {
long socket = super.socket(params.authenticate, params.encrypt);
try {
super.connect(socket, params.address, params.channel);
} catch (IOException e) {
super.close(socket);
throw e;
}
return socket;
}

The super.socket() line calls BluetoothPeer.socket which is the native
JNI method Java_com_intel_bluetooth_BluetoothPeer_socket(). It must
return a valid socket description which gets stored in the variable
"socket".

It is then passed to super.connect() which is the method
Java_com_intel_bluetooth_BluetoothPeer_connect(). There
connect(socket) fails with the last error code being the 10053.

Any ideas what might be causing this?

deanb...@gmail.com

unread,
Sep 7, 2007, 4:43:01 PM9/7/07
to bluecove-users
I'll spend some more time on this today, but here is what I've found
out so far.

The 10053 socket error is sometimes described as "The connection was
aborted by the software." After playing around with the code I'm
pretty sure in this case the "software" is actually the Bluetooth
stack on the phone. This error is generated by BlueCove's C++
connect() call. I believe this because if invalidate some of the
parameters I get appropriate error messages. For example if I close
the socket before connect I get that error or if I pass in an invalid
socket ID I get that error code.

I'm going to look into why BlueCove surfaces this error while Avetana
does not. One guess I have is there is some other connection open and
the phone only handles one so it gives the 10053 to mean "exceeded
maximum number of connections".

Any other ideas out there why the Bluetooth stack might abort a socket
connection attempt?

Vlad Skarzhevskyy

unread,
Sep 7, 2007, 7:26:07 PM9/7/07
to bluecov...@googlegroups.com
If u do service search this another con. Try to add sleep b4 making
con. 
I'm back tomorow. Fix 4 bugs r ready & tested.


--
Vlad

deanb...@gmail.com

unread,
Sep 7, 2007, 8:19:32 PM9/7/07
to bluecove-users
I figured this problem out and now everything is working. I will file
a bug for it too.

Here is the sequence of what was really happening:
(1) I did successfully connect the Bluetooth socket on Microsoft's
stack (connection = Connector.open())
(2) I successfully opened an output stream (out =
connection.openOutputStream()) and wrote to it
(3) I closed that output stream (out.close()) because I was done with
my initialization
(4) Bug --> BlueCove closed the connection (in addition to the output
stream)
(5) I tried to open an input stream (connection.openInputStream)
which BlueCove threw an IOException with no message for
(6) Bug --> My software didn't log anything because there was no
message making it hard for me to identify
(7) My software took the IOException and used it as a signal to re-
open the connection (Connector.open())
(8) The C++ connect() function returned an error code of 10053

What I don't know is why didn't I just open another connection? For
some reason connect() must not have been able to bind to the remote
address again so quickly after a socket close.

skarzh...@gmail.com

unread,
Sep 9, 2007, 2:04:52 PM9/9/07
to bluecove-users
Dean
I fixed the bugs submited by you. I would appreciate if you will do
some testing and conform that all works as expected in new version.
http://www.pyx4me.com/maven2-snapshot/net/sf/bluecove/bluecove/2.0.2-SNAPSHOT/

One outstanding Issue with disabled Bluetooth on a device would be
fixed later.

Really appreciate you efforts!
Vlad

Reply all
Reply to author
Forward
0 new messages