libutil++  1.9.3
 All Classes Functions Variables
UDPSocket.cpp
1 /*
2 ** libutil++
3 ** $Id: UDPSocket.cpp 1653 2016-02-28 19:54:59Z sella $
4 ** Copyright (c) 2011-2016 Digital Genesis, LLC. All Rights Reserved.
5 ** Released under the LGPL Version 2.1 License.
6 ** http://www.digitalgenesis.com
7 */
8 
9 static const char rcsid[] __attribute__((used)) = "$Id: UDPSocket.cpp 1653 2016-02-28 19:54:59Z sella $";
10 
11 #include "UDPSocket.h"
12 
13 #include <sys/types.h>
14 #include <sys/socket.h>
15 #include <string.h>
16 
17 using namespace sella::net;
18 
19 UDPSocket::UDPSocket(int family) throw (SocketException) : Socket(family, SOCK_DGRAM, IPPROTO_UDP) {
20 }
21 
22 UDPSocket::UDPSocket(int family, const IPAddressPort &addressport) throw (SocketException) : Socket(family, SOCK_DGRAM, IPPROTO_UDP) {
23  connect(addressport);
24 }
25 
26 UDPSocket::UDPSocket(int family, const IPAddress &address, const Port &port) throw (SocketException) : Socket(family, SOCK_DGRAM, IPPROTO_UDP) {
27  connect(address, port);
28 }
29 
30 UDPSocket::UDPSocket(int family, const std::string &address, unsigned short port) throw (SocketException) : Socket(family, SOCK_DGRAM, IPPROTO_UDP) {
31  connect(address, port);
32 }
33 
34 UDPSocket::UDPSocket(const IPAddressPort &addressport) throw (SocketException) : Socket(addressport.getFamily(), SOCK_DGRAM, IPPROTO_UDP) {
35  connect(addressport);
36 }
37 
38 UDPSocket::UDPSocket(const IPAddress &address, const Port &port) throw (SocketException) : Socket(address.getFamily(), SOCK_DGRAM, IPPROTO_UDP) {
39  connect(address, port);
40 }
41 
42 UDPSocket::~UDPSocket() {
43 }
44 
45 const UDPSocket::shared UDPSocket::shared_ptr(int family) throw (SocketException) {
46  return std::make_shared<UDPSocket>(family);
47 }
48 
49 const UDPSocket::shared UDPSocket::shared_ptr(int family, const IPAddressPort &addressport) throw (SocketException) {
50  return std::make_shared<UDPSocket>(family, addressport);
51 }
52 
53 const UDPSocket::shared UDPSocket::shared_ptr(int family, const IPAddress &address, const Port &port) throw (SocketException) {
54  return std::make_shared<UDPSocket>(family, address, port);
55 }
56 
57 const UDPSocket::shared UDPSocket::shared_ptr(int family, const std::string &address, unsigned short port) throw (SocketException) {
58  return std::make_shared<UDPSocket>(family, address, port);
59 }
60 
61 /*
62 ** vim: noet ts=3 sw=3
63 */