summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/client
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2008-08-05 17:03:16 +0000
committerGordon Sim <gsim@apache.org>2008-08-05 17:03:16 +0000
commitbd47fd629bb2356df93af70b174a6a070f3a58cc (patch)
treec92b2cc932fe806ce9e41521de9f4d01557ec2ba /cpp/src/qpid/client
parent6bed4cf29dda54560af44d16143fa4b24b65245b (diff)
downloadqpid-python-bd47fd629bb2356df93af70b174a6a070f3a58cc.tar.gz
* revised approach for setting tcp-nodelay on client to avoid breaking platform abstractions
* added ability to set tcp-nodelay on server side of the socket also Merged from r682785. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@682791 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/client')
-rw-r--r--cpp/src/qpid/client/ConnectionSettings.cpp12
-rw-r--r--cpp/src/qpid/client/ConnectionSettings.h13
-rw-r--r--cpp/src/qpid/client/Connector.cpp2
3 files changed, 14 insertions, 13 deletions
diff --git a/cpp/src/qpid/client/ConnectionSettings.cpp b/cpp/src/qpid/client/ConnectionSettings.cpp
index ea4e20b529..6bc220cd41 100644
--- a/cpp/src/qpid/client/ConnectionSettings.cpp
+++ b/cpp/src/qpid/client/ConnectionSettings.cpp
@@ -21,10 +21,8 @@
#include "ConnectionSettings.h"
#include "qpid/log/Logger.h"
-#include "qpid/sys/posix/check.h"
+#include "qpid/sys/Socket.h"
#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
namespace qpid {
namespace client {
@@ -45,13 +43,11 @@ ConnectionSettings::ConnectionSettings() :
ConnectionSettings::~ConnectionSettings() {}
-void ConnectionSettings::configurePosixTcpSocket(int fd) const
+void ConnectionSettings::configureSocket(qpid::sys::Socket& socket) const
{
if (tcpNoDelay) {
- int flag = 1;
- int result = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(flag));
- QPID_POSIX_CHECK(result);
- QPID_LOG(debug, "Set TCP_NODELAY");
+ socket.setTcpNoDelay(tcpNoDelay);
+ QPID_LOG(info, "Set TCP_NODELAY");
}
}
diff --git a/cpp/src/qpid/client/ConnectionSettings.h b/cpp/src/qpid/client/ConnectionSettings.h
index a2b85c5134..5e93b3103e 100644
--- a/cpp/src/qpid/client/ConnectionSettings.h
+++ b/cpp/src/qpid/client/ConnectionSettings.h
@@ -25,26 +25,31 @@
#include "qpid/Options.h"
#include "qpid/log/Options.h"
#include "qpid/Url.h"
-#include "qpid/sys/Socket.h"
#include <iostream>
#include <exception>
namespace qpid {
+
+namespace sys {
+class Socket;
+}
+
namespace client {
/**
* Settings for a Connection.
*/
-struct ConnectionSettings : public sys::Socket::Configuration {
+struct ConnectionSettings {
ConnectionSettings();
virtual ~ConnectionSettings();
/**
- * Applies any tcp specific options to the sockets file descriptor
+ * Allows socket to be configured; default only sets tcp-nodelay
+ * based on the flag set. Can be overridden.
*/
- virtual void configurePosixTcpSocket(int fd) const;
+ virtual void configureSocket(qpid::sys::Socket&) const;
/**
* The host (or ip address) to connect to (defaults to 'localhost').
diff --git a/cpp/src/qpid/client/Connector.cpp b/cpp/src/qpid/client/Connector.cpp
index b6fc42a74a..524155b929 100644
--- a/cpp/src/qpid/client/Connector.cpp
+++ b/cpp/src/qpid/client/Connector.cpp
@@ -60,7 +60,7 @@ Connector::Connector(ProtocolVersion ver,
impl(cimpl)
{
QPID_LOG(debug, "Connector created for " << version);
- socket.configure(settings);
+ settings.configureSocket(socket);
}
Connector::~Connector() {