These depend on a system-specific type, so they can't be in a public
header.
{
#ifndef WIN32
timeval tv = Time::rawtime_to_timeval(timeout.raw());
{
#ifndef WIN32
timeval tv = Time::rawtime_to_timeval(timeout.raw());
- set_option(SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(timeval));
- set_option(SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(timeval));
+ priv->set_option(SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(timeval));
+ priv->set_option(SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(timeval));
#else
DWORD msecs = static_cast<DWORD>(timeout/Time::msec);
#else
DWORD msecs = static_cast<DWORD>(timeout/Time::msec);
- set_option(SOL_SOCKET, SO_RCVTIMEO, &msecs, sizeof(DWORD));
- set_option(SOL_SOCKET, SO_SNDTIMEO, &msecs, sizeof(DWORD));
+ priv->set_option(SOL_SOCKET, SO_RCVTIMEO, &msecs, sizeof(DWORD));
+ priv->set_option(SOL_SOCKET, SO_SNDTIMEO, &msecs, sizeof(DWORD));
-int Socket::set_option(int level, int optname, const void *optval, socklen_t optlen)
+
+int Socket::Private::set_option(int level, int optname, const void *optval, socklen_t optlen)
- return setsockopt(priv->handle, level, optname, reinterpret_cast<const char *>(optval), optlen);
+ return setsockopt(handle, level, optname, reinterpret_cast<const char *>(optval), optlen);
- return setsockopt(priv->handle, level, optname, optval, optlen);
+ return setsockopt(handle, level, optname, optval, optlen);
-int Socket::get_option(int level, int optname, void *optval, socklen_t *optlen) const
+int Socket::Private::get_option(int level, int optname, void *optval, socklen_t *optlen)
- return getsockopt(priv->handle, level, optname, reinterpret_cast<char *>(optval), optlen);
+ return getsockopt(handle, level, optname, reinterpret_cast<char *>(optval), optlen);
- return getsockopt(priv->handle, level, optname, optval, optlen);
+ return getsockopt(handle, level, optname, optval, optlen);
namespace Msp {
namespace Net {
namespace Msp {
namespace Net {
-#ifdef WIN32
-typedef int socklen_t;
-#endif
-
-
class bad_socket_state: public std::logic_error
{
public:
class bad_socket_state: public std::logic_error
{
public:
const SockAddr &get_local_address() const;
void set_timeout(const Time::TimeDelta &);
const SockAddr &get_local_address() const;
void set_timeout(const Time::TimeDelta &);
-protected:
- int set_option(int, int, const void *, socklen_t);
- int get_option(int, int, void *, socklen_t *) const;
namespace Msp {
namespace Net {
namespace Msp {
namespace Net {
+#ifdef WIN32
+typedef int socklen_t;
+#endif
+
struct Socket::Private
{
#ifdef WIN32
struct Socket::Private
{
#ifdef WIN32
/* On POSIX platforms this is the same as the handle. This might seem
strange but it allows the same syntax on both POSIX and Windows. */
IO::Handle event;
/* On POSIX platforms this is the same as the handle. This might seem
strange but it allows the same syntax on both POSIX and Windows. */
IO::Handle event;
+
+ int set_option(int, int, const void *, socklen_t);
+ int get_option(int, int, void *, socklen_t *);
int err;
socklen_t len = sizeof(int);
int err;
socklen_t len = sizeof(int);
- get_option(SOL_SOCKET, SO_ERROR, &err, &len);
+ priv->get_option(SOL_SOCKET, SO_ERROR, &err, &len);
{
int err;
socklen_t len = sizeof(err);
{
int err;
socklen_t len = sizeof(err);
- get_option(SOL_SOCKET, SO_ERROR, &err, &len);
+ priv->get_option(SOL_SOCKET, SO_ERROR, &err, &len);
connecting = false;
connected = (err==0);
connecting = false;
connected = (err==0);