-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52a510a
commit e0146d9
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* @file udpsocket.cpp | ||
* @author Krisna Pranav | ||
* @brief udpsocket | ||
* @version 6.0 | ||
* @date 2023-10-03 | ||
* | ||
* @copyright Copyright (c) 2021 - 2023 pranaOS Developers, Krisna Pranav | ||
* | ||
*/ | ||
|
||
#include <errno.h> | ||
#include <libcore/udpsocket.h> | ||
#include <sys/socket.h> | ||
|
||
#ifndef SOCK_NONBLOCK | ||
# include <sys/ioctl.h> | ||
#endif | ||
|
||
namespace Core | ||
{ | ||
/** | ||
* @param parent | ||
*/ | ||
UDPSocket::UDPSocket(Object* parent) | ||
: Socket(Socket::Type::UDP, parent) | ||
{ | ||
int fd = socket(AF_INET, SOCK_DGRAM, 0); | ||
int option = 1; | ||
ioctl(fd, FIONBIO, &option); | ||
|
||
if (fd < 0) { | ||
set_error(errno); | ||
} else { | ||
set_fd(fd); | ||
set_error(0); | ||
} | ||
} | ||
|
||
/// @brief Destroy the UDPSocket::UDPSocket object | ||
UDPSocket::~UDPSocket() | ||
{} | ||
} // namespace Core |