diff options
author | Eliot Horowitz <eliot@10gen.com> | 2011-07-06 11:27:43 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-07-06 17:50:09 -0400 |
commit | b382625b8ed2e775011dd47a16ec8ff60989010b (patch) | |
tree | 41ed9c855f910fa209e5a58a4b95300534b48db6 /util/net | |
parent | 1e32965aebfe1d007a9ca5d581ca887f7ce914ab (diff) | |
download | mongo-b382625b8ed2e775011dd47a16ec8ff60989010b.tar.gz |
remove unused UDPConnection
Diffstat (limited to 'util/net')
-rw-r--r-- | util/net/sock.cpp | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/util/net/sock.cpp b/util/net/sock.cpp index db8eb43381e..ee4a6acee04 100644 --- a/util/net/sock.cpp +++ b/util/net/sock.cpp @@ -114,90 +114,6 @@ namespace mongo { return addr; } - class UDPConnection { - public: - UDPConnection() { - sock = 0; - } - ~UDPConnection() { - if ( sock ) { - closesocket(sock); - sock = 0; - } - } - bool init(const SockAddr& myAddr); - int recvfrom(char *buf, int len, SockAddr& sender); - int sendto(char *buf, int len, const SockAddr& EndPoint); - int mtu(const SockAddr& sa) { - return sa.isLocalHost() ? 16384 : 1480; - } - - SOCKET sock; - }; - - inline int UDPConnection::recvfrom(char *buf, int len, SockAddr& sender) { - return ::recvfrom(sock, buf, len, 0, sender.raw(), &sender.addressSize); - } - - inline int UDPConnection::sendto(char *buf, int len, const SockAddr& EndPoint) { - if ( 0 && rand() < (RAND_MAX>>4) ) { - out() << " NOTSENT "; - return 0; - } - return ::sendto(sock, buf, len, 0, EndPoint.raw(), EndPoint.addressSize); - } - - inline bool UDPConnection::init(const SockAddr& myAddr) { - sock = socket(myAddr.getType(), SOCK_DGRAM, IPPROTO_UDP); - if ( sock == INVALID_SOCKET ) { - out() << "invalid socket? " << errnoWithDescription() << endl; - return false; - } - if ( ::bind(sock, myAddr.raw(), myAddr.addressSize) != 0 ) { - out() << "udp init failed" << endl; - closesocket(sock); - sock = 0; - return false; - } - socklen_t optLen; - int rcvbuf; - if (getsockopt(sock, - SOL_SOCKET, - SO_RCVBUF, - (char*)&rcvbuf, - &optLen) != -1) - out() << "SO_RCVBUF:" << rcvbuf << endl; - return true; - } - - void sendtest() { - out() << "sendtest\n"; - SockAddr me(27016); - SockAddr dest("127.0.0.1", 27015); - UDPConnection c; - if ( c.init(me) ) { - char buf[256]; - out() << "sendto: "; - out() << c.sendto(buf, sizeof(buf), dest) << " " << errnoWithDescription() << endl; - } - out() << "end\n"; - } - - void listentest() { - out() << "listentest\n"; - SockAddr me(27015); - SockAddr sender; - UDPConnection c; - if ( c.init(me) ) { - char buf[256]; - out() << "recvfrom: "; - out() << c.recvfrom(buf, sizeof(buf), sender) << " " << errnoWithDescription() << endl; - } - out() << "end listentest\n"; - } - - void xmain(); - #if defined(_WIN32) namespace { struct WinsockInit { |