From 06f88ef296d1b9e988a4b813085a17974c4bd199 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Fri, 5 Dec 2014 13:11:12 +0100 Subject: [PATCH] Let socket library return correct socket number in all cases. --- lib/socket.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/socket.cpp b/lib/socket.cpp index e69ffc79..dc554a11 100644 --- a/lib/socket.cpp +++ b/lib/socket.cpp @@ -283,7 +283,16 @@ void Socket::Connection::drop() { /// Returns internal socket number. int Socket::Connection::getSocket() { - return sock; + if (sock != -1){ + return sock; + } + if (pipes[0] != -1) { + return pipes[0]; + } + if (pipes[1] != -1) { + return pipes[1]; + } + return -1; } /// Returns a string describing the last error that occured.