2012-04-29 20:52:25 +02:00
|
|
|
//
|
|
|
|
// DatagramSocketImpl.cpp
|
|
|
|
//
|
|
|
|
// Library: Net
|
|
|
|
// Package: Sockets
|
|
|
|
// Module: DatagramSocketImpl
|
|
|
|
//
|
|
|
|
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
|
|
|
|
// and Contributors.
|
|
|
|
//
|
2014-05-04 21:02:42 +02:00
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
2012-04-29 20:52:25 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#include "Poco/Net/DatagramSocketImpl.h"
|
|
|
|
#include "Poco/Net/NetException.h"
|
|
|
|
|
|
|
|
|
|
|
|
using Poco::InvalidArgumentException;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Poco {
|
|
|
|
namespace Net {
|
|
|
|
|
|
|
|
|
|
|
|
DatagramSocketImpl::DatagramSocketImpl()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-31 16:53:06 +01:00
|
|
|
DatagramSocketImpl::DatagramSocketImpl(SocketAddress::Family family)
|
2012-04-29 20:52:25 +02:00
|
|
|
{
|
2017-10-31 16:53:06 +01:00
|
|
|
if (family == SocketAddress::IPv4)
|
2012-04-29 20:52:25 +02:00
|
|
|
init(AF_INET);
|
|
|
|
#if defined(POCO_HAVE_IPv6)
|
2017-10-31 16:53:06 +01:00
|
|
|
else if (family == SocketAddress::IPv6)
|
2012-04-29 20:52:25 +02:00
|
|
|
init(AF_INET6);
|
2017-10-31 16:53:06 +01:00
|
|
|
#endif
|
|
|
|
#if defined(POCO_OS_FAMILY_UNIX)
|
|
|
|
else if (family == SocketAddress::UNIX_LOCAL)
|
|
|
|
init(AF_UNIX);
|
2012-04-29 20:52:25 +02:00
|
|
|
#endif
|
|
|
|
else throw InvalidArgumentException("Invalid or unsupported address family passed to DatagramSocketImpl");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DatagramSocketImpl::DatagramSocketImpl(poco_socket_t sockfd): SocketImpl(sockfd)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DatagramSocketImpl::~DatagramSocketImpl()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DatagramSocketImpl::init(int af)
|
|
|
|
{
|
|
|
|
initSocket(af, SOCK_DGRAM);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} } // namespace Poco::Net
|