00001
00002
00003
00004
00005
00006
00007
00008
00009 static const char rcsid[] __attribute__((used)) = "$Id: SocketPair.cpp 1197 2014-10-14 22:26:11Z sella $";
00010
00011 #include "SocketPair.h"
00012
00013 #include <unistd.h>
00014
00015 using namespace sella::net;
00016
00017 SocketPair::SocketPair() throw (SocketException) {
00018 int fd[2];
00019
00020 if (::socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != 0) {
00021 THROW2(SocketException, "socketpair()");
00022 }
00023
00024 first = UnixSocket::shared_ptr(fd[0]);
00025 second = UnixSocket::shared_ptr(fd[1]);
00026 }
00027
00028 SocketPair::~SocketPair() {
00029 }
00030
00031 UnixSocket::shared SocketPair::getFirst(void) {
00032 return first;
00033 }
00034
00035 UnixSocket::shared SocketPair::getSecond(void) {
00036 return second;
00037 }
00038
00039 const SocketPair::shared SocketPair::shared_ptr() throw (SocketException) {
00040 return std::make_shared<SocketPair>();
00041 }
00042
00043
00044
00045