I am developing a networking-based app for the blackberry playbook using Qt4.8.3, part of which involves storing a QAbstractSocket in a QScopedPointer as follows:
QScopedPointer<QAbstractSocket> nntp;
In my implementation, I store either a QSslSocket or a QTcpSocket (both of which inherit from QAbstractSocket) depending on whether the conenction is to be encrypted, i.e.,
if(ssl) {
nntp.reset(new QSslSocket(this));
(dynamic_cast<QSslSocket*>(nntp.data())))->connectToHostEncrypted(server, port);
} else {
nntp.reset(new QTcpSocket(this));
nntp->connectToHost(server, port);
}
When going down the ssl route (non-ssl works fine!), I end up with the following run time error:
virtual void QEventDispatcherBlackberry::unregisterSocketNotifier(QSocketNotifier*) bps_remove_fd() failed 19
The error is probably blackberry related given the error description and the fact that the code works as expected on other platforms (tested on mac and linux). (Note, the number 19 refers to the file descriptor).
Any ideas why I am seeing this error and how I can fix it?
Thanks,
Ben.
EDIT: I've just realised that instead of using the pointer, I can just have a single QSslSocket and treat it as a regular QTcpSocket when in non-ssl mode. Far easier. I would still like to know the reason for the above error however
We can have a look at the source code in order to see what is happening. The source code of
unregisterSocketNotifieris:And do a correlation with
bps_remove_fddocumentation which says:The only clues about what could make
bps_remove_fdfail are the possibility thatfdis not present, which would mean that your socket does not have any valid file descriptor. The other error could be that for whichever reason not specified, the file exists but is not removed.The variable
errnoshould be set, so you may have a more complete error description if you look at it - I did not try though, I don't have what it takes -.I bet
bps_remove_fdworks on the same principle than POSIX'sclose(int fd), so I had a look atclose's documentation to see what could cause a failure. It states that it shall/may fail in the following cases:closemay be interrupted by a signal (shall fail).I would have made this answer a comment since it does not really answer the question in your particular case, but I hope it may at least help you understand what's going on a little bit more :)