1 | // |
---|---|
2 | // DatagramSocketImpl.cpp |
3 | // |
4 | // Library: Net |
5 | // Package: Sockets |
6 | // Module: DatagramSocketImpl |
7 | // |
8 | // Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH. |
9 | // and Contributors. |
10 | // |
11 | // SPDX-License-Identifier: BSL-1.0 |
12 | // |
13 | |
14 | |
15 | #include "Poco/Net/DatagramSocketImpl.h" |
16 | #include "Poco/Net/NetException.h" |
17 | |
18 | |
19 | using Poco::InvalidArgumentException; |
20 | |
21 | |
22 | namespace Poco { |
23 | namespace Net { |
24 | |
25 | |
26 | DatagramSocketImpl::DatagramSocketImpl() |
27 | { |
28 | } |
29 | |
30 | |
31 | DatagramSocketImpl::DatagramSocketImpl(SocketAddress::Family family) |
32 | { |
33 | if (family == SocketAddress::IPv4) |
34 | init(AF_INET); |
35 | #if defined(POCO_HAVE_IPv6) |
36 | else if (family == SocketAddress::IPv6) |
37 | init(AF_INET6); |
38 | #endif |
39 | #if defined(POCO_OS_FAMILY_UNIX) |
40 | else if (family == SocketAddress::UNIX_LOCAL) |
41 | init(AF_UNIX); |
42 | #endif |
43 | else throw InvalidArgumentException("Invalid or unsupported address family passed to DatagramSocketImpl"); |
44 | } |
45 | |
46 | |
47 | DatagramSocketImpl::DatagramSocketImpl(poco_socket_t sockfd): SocketImpl(sockfd) |
48 | { |
49 | } |
50 | |
51 | |
52 | DatagramSocketImpl::~DatagramSocketImpl() |
53 | { |
54 | } |
55 | |
56 | |
57 | void DatagramSocketImpl::init(int af) |
58 | { |
59 | initSocket(af, SOCK_DGRAM); |
60 | } |
61 | |
62 | |
63 | } } // namespace Poco::Net |
64 |