X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FSocket.hh;fp=src%2FMoof%2FSocket.hh;h=fcf1a3edbfc0464395941929c222d699d53a1e91;hp=948f9423785ea944087f29e580b5ef5b4f6f4391;hb=7ade2da0367685e098181d7124c9ba145a010626;hpb=264bdbb09bc86797f1f80d151ac408cb780b9355 diff --git a/src/Moof/Socket.hh b/src/Moof/Socket.hh index 948f942..fcf1a3e 100644 --- a/src/Moof/Socket.hh +++ b/src/Moof/Socket.hh @@ -390,6 +390,7 @@ public: int set(int option, int value = 0) { + if (mFd == -1) mFd = socket(mAddress.family(), mAddress.type(), 0); if (option == SO_NONBLOCK) { #ifdef HAVE_FCNTL @@ -404,12 +405,14 @@ public: int set(int option, const std::string& value) { + if (mFd == -1) mFd = socket(mAddress.family(), mAddress.type(), 0); return setsockopt(mFd, SOL_SOCKET, option, value.data(), value.length()); } int get(int option, int& value) { + if (mFd == -1) mFd = socket(mAddress.family(), mAddress.type(), 0); if (option == SO_NONBLOCK) { #ifdef HAVE_FCNTL @@ -425,6 +428,7 @@ public: int get(int option, std::string& value) { + if (mFd == -1) mFd = socket(mAddress.family(), mAddress.type(), 0); char str[64] = {'\0'}; socklen_t optlen = sizeof(str); int result = getsockopt(mFd, SOL_SOCKET, option, &str, &optlen);