ladybird/Userland/Libraries/LibCore/UDPSocket.cpp
Brian Gianforcaro 1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00

42 lines
713 B
C++

/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibCore/UDPSocket.h>
#include <errno.h>
#include <sys/socket.h>
#ifndef SOCK_NONBLOCK
# include <sys/ioctl.h>
#endif
namespace Core {
UDPSocket::UDPSocket(Object* parent)
: Socket(Socket::Type::UDP, parent)
{
#ifdef SOCK_NONBLOCK
int fd = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, 0);
#else
int fd = socket(AF_INET, SOCK_DGRAM, 0);
int option = 1;
ioctl(fd, FIONBIO, &option);
#endif
if (fd < 0) {
set_error(errno);
} else {
set_fd(fd);
set_mode(IODevice::ReadWrite);
set_error(0);
}
}
UDPSocket::~UDPSocket()
{
}
}