summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/network/socket/qsymbiansocketengine.cpp20
-rw-r--r--tests/auto/platformsocketengine/tst_platformsocketengine.cpp25
2 files changed, 34 insertions, 11 deletions
diff --git a/src/network/socket/qsymbiansocketengine.cpp b/src/network/socket/qsymbiansocketengine.cpp
index b63dbf6..90d5265 100644
--- a/src/network/socket/qsymbiansocketengine.cpp
+++ b/src/network/socket/qsymbiansocketengine.cpp
@@ -188,6 +188,7 @@ bool QSymbianSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType so
else
err = nativeSocket.Open(socketServer, family, type, protocol); //TODO: FIXME - deprecated API, make sure we always have a connection instead
+ //TODO: combine error handling with setError
if (err != KErrNone) {
switch (err) {
case KErrNotSupported:
@@ -375,6 +376,12 @@ bool QSymbianSocketEngine::initialize(int socketDescriptor, QAbstractSocket::Soc
close();
return false;
}
+
+ // Make sure we receive out-of-band data
+ if (socketType == QAbstractSocket::TcpSocket
+ && !setOption(ReceiveOutOfBandData, 1)) {
+ qWarning("QNativeSocketEngine::initialize unable to inline out-of-band data");
+ }
}
d->socketState = socketState;
@@ -566,11 +573,11 @@ bool QSymbianSocketEngine::connectToHost(const QHostAddress &addr, quint16 port)
TInetAddr nativeAddr;
d->setPortAndAddress(nativeAddr, port, addr);
- //TODO: async connect with active object - from here to end of function is a mess
TRequestStatus status;
d->nativeSocket.Connect(nativeAddr, status);
User::WaitForRequest(status);
TInt err = status.Int();
+ //TODO: combine with setError(int)
if (err) {
switch (err) {
case KErrWouldBlock:
@@ -674,7 +681,8 @@ bool QSymbianSocketEngine::listen()
// for a mobile platform
TInt err = d->nativeSocket.Listen(50);
if (err) {
- switch (errno) {
+ //TODO: combine with setError(int)
+ switch (err) {
case KErrInUse:
d->setError(QAbstractSocket::AddressInUseError,
d->PortInuseErrorString);
@@ -702,7 +710,6 @@ int QSymbianSocketEngine::accept()
{
Q_D(QSymbianSocketEngine);
RSocket blankSocket;
- //TODO: this is unbelievably broken, needs to be properly async
blankSocket.Open(d->socketServer);
TRequestStatus status;
d->nativeSocket.Accept(blankSocket, status);
@@ -717,10 +724,10 @@ int QSymbianSocketEngine::accept()
qint64 QSymbianSocketEngine::bytesAvailable() const
{
Q_D(const QSymbianSocketEngine);
+ Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::bytesAvailable(), -1);
+ Q_CHECK_NOT_STATE(QNativeSocketEngine::bytesAvailable(), QAbstractSocket::UnconnectedState, false);
int nbytes = 0;
qint64 available = 0;
- // FIXME is this the right thing also for UDP?
- // What is expected for UDP, the length for the next packet I guess?
TInt err = d->nativeSocket.GetOpt(KSOReadBytesPending, KSOLSocket, nbytes);
if (err)
return 0;
@@ -735,6 +742,9 @@ qint64 QSymbianSocketEngine::bytesAvailable() const
bool QSymbianSocketEngine::hasPendingDatagrams() const
{
Q_D(const QSymbianSocketEngine);
+ Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::hasPendingDatagrams(), false);
+ Q_CHECK_NOT_STATE(QNativeSocketEngine::hasPendingDatagrams(), QAbstractSocket::UnconnectedState, false);
+ Q_CHECK_TYPE(QNativeSocketEngine::hasPendingDatagrams(), QAbstractSocket::UdpSocket, false);
int nbytes;
TInt err = d->nativeSocket.GetOpt(KSOReadBytesPending,KSOLSocket, nbytes);
return err == KErrNone && nbytes > 0;
diff --git a/tests/auto/platformsocketengine/tst_platformsocketengine.cpp b/tests/auto/platformsocketengine/tst_platformsocketengine.cpp
index a7b4235..2fb3724 100644
--- a/tests/auto/platformsocketengine/tst_platformsocketengine.cpp
+++ b/tests/auto/platformsocketengine/tst_platformsocketengine.cpp
@@ -213,9 +213,6 @@ void tst_PlatformSocketEngine::simpleConnectToIMAP()
//---------------------------------------------------------------------------
void tst_PlatformSocketEngine::udpLoopbackTest()
{
-#ifdef SYMBIAN_WINSOCK_CONNECTIVITY
- QSKIP("Not working on Emulator without WinPCAP", SkipAll);
-#endif
PLATFORMSOCKETENGINE udpSocket;
// Initialize device #1
@@ -264,9 +261,6 @@ void tst_PlatformSocketEngine::udpLoopbackTest()
//---------------------------------------------------------------------------
void tst_PlatformSocketEngine::udpIPv6LoopbackTest()
{
-#if defined(Q_OS_SYMBIAN)
- QSKIP("Symbian: IPv6 is not yet supported", SkipAll);
-#endif
PLATFORMSOCKETENGINE udpSocket;
// Initialize device #1
@@ -695,7 +689,18 @@ void tst_PlatformSocketEngine::receiveUrgentData()
// The server sends an urgent message
msg = 'Q';
+#if defined(Q_OS_SYMBIAN)
+ RSocket sock;
+ QVERIFY(QSymbianSocketManager::instance().lookupSocket(socketDescriptor, sock));
+ TRequestStatus stat;
+ TSockXfrLength len;
+ sock.Send(TPtrC8((TUint8*)&msg,1), KSockWriteUrgent, stat, len);
+ User::WaitForRequest(stat);
+ QVERIFY(stat == KErrNone);
+ QCOMPARE(len(), 1);
+#else
QCOMPARE(int(::send(socketDescriptor, &msg, sizeof(msg), MSG_OOB)), 1);
+#endif
// The client receives the urgent message
QVERIFY(client.waitForRead());
@@ -708,7 +713,15 @@ void tst_PlatformSocketEngine::receiveUrgentData()
// The client sends an urgent message
msg = 'T';
int clientDescriptor = client.socketDescriptor();
+#if defined(Q_OS_SYMBIAN)
+ QVERIFY(QSymbianSocketManager::instance().lookupSocket(clientDescriptor, sock));
+ sock.Send(TPtrC8((TUint8*)&msg,1), KSockWriteUrgent, stat, len);
+ User::WaitForRequest(stat);
+ QVERIFY(stat == KErrNone);
+ QCOMPARE(len(), 1);
+#else
QCOMPARE(int(::send(clientDescriptor, &msg, sizeof(msg), MSG_OOB)), 1);
+#endif
// The server receives the urgent message
QVERIFY(serverSocket.waitForRead());