summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qnativesocketengine_unix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/socket/qnativesocketengine_unix.cpp')
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp63
1 files changed, 51 insertions, 12 deletions
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index 4388382db..332bc6de0 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -173,7 +173,11 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc
int protocol = AF_INET;
#endif
int type = (socketType == QAbstractSocket::UdpSocket) ? SOCK_DGRAM : SOCK_STREAM;
- int socket = qt_safe_socket(protocol, type, 0);
+#ifdef Q_OS_SYMBIAN
+ int socket = ::socket(protocol, type, 0);
+#else
+ int socket = qt_safe_socket(protocol, type, 0);
+#endif
if (socket <= 0) {
switch (errno) {
@@ -294,7 +298,11 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt
}
#else // Q_OS_VXWORKS
int onoff = 1;
+#ifdef Q_OS_SYMBIAN
+ if (::ioctl(socketDescriptor, FIONBIO, &onoff) < 0) {
+#else
if (qt_safe_ioctl(socketDescriptor, FIONBIO, &onoff) < 0) {
+#endif
#ifdef QNATIVESOCKETENGINE_DEBUG
perror("QNativeSocketEnginePrivate::setOption(): ioctl(FIONBIO, 1) failed");
#endif
@@ -370,9 +378,11 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &addr, quint16
} else {
// unreachable
}
-
+#ifdef Q_OS_SYMBIAN
+ int connectResult = ::connect(socketDescriptor, sockAddrPtr, sockAddrSize);
+#else
int connectResult = qt_safe_connect(socketDescriptor, sockAddrPtr, sockAddrSize);
-
+#endif
if (connectResult == -1) {
switch (errno) {
case EISCONN:
@@ -513,7 +523,11 @@ bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &address, quint16
bool QNativeSocketEnginePrivate::nativeListen(int backlog)
{
+#ifdef Q_OS_SYMBIAN
+ if (::listen(socketDescriptor, backlog) < 0) {
+#else
if (qt_safe_listen(socketDescriptor, backlog) < 0) {
+#endif
switch (errno) {
case EADDRINUSE:
setError(QAbstractSocket::AddressInUseError,
@@ -540,8 +554,11 @@ bool QNativeSocketEnginePrivate::nativeListen(int backlog)
int QNativeSocketEnginePrivate::nativeAccept()
{
+#ifdef Q_OS_SYMBIAN
+ int acceptedDescriptor = ::accept(socketDescriptor, 0, 0);
+#else
int acceptedDescriptor = qt_safe_accept(socketDescriptor, 0, 0);
-
+#endif
//check if we have vaild descriptor at all
if(acceptedDescriptor > 0) {
// Ensure that the socket is closed on exec*()
@@ -558,7 +575,11 @@ qint64 QNativeSocketEnginePrivate::nativeBytesAvailable() const
int nbytes = 0;
// gives shorter than true amounts on Unix domain sockets.
qint64 available = 0;
+#ifdef Q_OS_SYMBIAN
+ if (::ioctl(socketDescriptor, FIONREAD, (char *) &nbytes) >= 0)
+#else
if (qt_safe_ioctl(socketDescriptor, FIONREAD, (char *) &nbytes) >= 0)
+#endif
available = (qint64) nbytes;
#if defined (QNATIVESOCKETENGINE_DEBUG)
@@ -690,8 +711,13 @@ qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 l
// ignore the SIGPIPE signal
qt_ignore_sigpipe();
+#ifdef Q_OS_SYMBIAN
+ ssize_t sentBytes = ::sendto(socketDescriptor, data, len,
+ 0, sockAddrPtr, sockAddrSize);
+#else
ssize_t sentBytes = qt_safe_sendto(socketDescriptor, data, len,
0, sockAddrPtr, sockAddrSize);
+#endif
if (sentBytes < 0) {
switch (errno) {
@@ -788,7 +814,12 @@ void QNativeSocketEnginePrivate::nativeClose()
#if defined (QNATIVESOCKETENGINE_DEBUG)
qDebug("QNativeSocketEngine::nativeClose()");
#endif
- qt_safe_close(socketDescriptor);
+
+#ifdef Q_OS_SYMBIAN
+ ::close(socketDescriptor);
+#else
+ qt_safe_close(socketDescriptor);
+#endif
}
qint64 QNativeSocketEnginePrivate::nativeWrite(const char *data, qint64 len)
@@ -802,7 +833,11 @@ qint64 QNativeSocketEnginePrivate::nativeWrite(const char *data, qint64 len)
// of an interrupting signal.
ssize_t writtenBytes;
do {
+#ifdef Q_OS_SYMBIAN
+ writtenBytes = ::write(socketDescriptor, data, len);
+#else
writtenBytes = qt_safe_write(socketDescriptor, data, len);
+#endif
// writtenBytes = QT_WRITE(socketDescriptor, data, len); ### TODO S60: Should this line be removed or the one above it?
} while (writtenBytes < 0 && errno == EINTR);
@@ -845,7 +880,11 @@ qint64 QNativeSocketEnginePrivate::nativeRead(char *data, qint64 maxSize)
ssize_t r = 0;
do {
+#ifdef Q_OS_SYMBIAN
+ r = ::read(socketDescriptor, data, maxSize);
+#else
r = qt_safe_read(socketDescriptor, data, maxSize);
+#endif
} while (r == -1 && errno == EINTR);
if (r < 0) {
@@ -904,16 +943,16 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool selectForRead) co
int retval;
if (selectForRead)
-#ifndef Q_OS_SYMBIAN
- retval = qt_safe_select(socketDescriptor + 1, &fds, 0, 0, timeout < 0 ? 0 : &tv);
+#ifdef Q_OS_SYMBIAN
+ retval = ::select(socketDescriptor + 1, &fds, 0, &fdexception, timeout < 0 ? 0 : &tv);
#else
- retval = qt_safe_select(socketDescriptor + 1, &fds, 0, &fdexception, timeout < 0 ? 0 : &tv);
+ retval = qt_safe_select(socketDescriptor + 1, &fds, 0, 0, timeout < 0 ? 0 : &tv);
#endif
else
-#ifndef Q_OS_SYMBIAN
- retval = qt_safe_select(socketDescriptor + 1, 0, &fds, 0, timeout < 0 ? 0 : &tv);
+#ifdef Q_OS_SYMBIAN
+ retval = ::select(socketDescriptor + 1, 0, &fds, &fdexception, timeout < 0 ? 0 : &tv);
#else
- retval = qt_safe_select(socketDescriptor + 1, 0, &fds, &fdexception, timeout < 0 ? 0 : &tv);
+ retval = qt_safe_select(socketDescriptor + 1, 0, &fds, 0, timeout < 0 ? 0 : &tv);
#endif
@@ -965,7 +1004,7 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool c
timer.start();
do {
- ret = qt_safe_select(socketDescriptor + 1, &fdread, &fdwrite, &fdexception, timeout < 0 ? 0 : &tv);
+ ret = ::select(socketDescriptor + 1, &fdread, &fdwrite, &fdexception, timeout < 0 ? 0 : &tv);
bool selectForExec = false;
if(ret != 0) {
if(ret < 0) {