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
19using Poco::InvalidArgumentException;
20
21
22namespace Poco {
23namespace Net {
24
25
26DatagramSocketImpl::DatagramSocketImpl()
27{
28}
29
30
31DatagramSocketImpl::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
47DatagramSocketImpl::DatagramSocketImpl(poco_socket_t sockfd): SocketImpl(sockfd)
48{
49}
50
51
52DatagramSocketImpl::~DatagramSocketImpl()
53{
54}
55
56
57void DatagramSocketImpl::init(int af)
58{
59 initSocket(af, SOCK_DGRAM);
60}
61
62
63} } // namespace Poco::Net
64