refactor: make EStreamType enum Class StreamType, and conform members to naming conventions
This commit is contained in:
parent
879283f46f
commit
47d44db497
7 changed files with 12 additions and 12 deletions
|
|
@ -61,10 +61,10 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Supported socket types
|
//! Supported socket types
|
||||||
enum ESocketType
|
enum class SocketType : uint8_t
|
||||||
{
|
{
|
||||||
kDGRAM,
|
DataGram,
|
||||||
kSTREAM
|
Stream
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Events for \c poll()
|
//! Events for \c poll()
|
||||||
|
|
@ -105,7 +105,7 @@ public:
|
||||||
/*!
|
/*!
|
||||||
The socket is an opaque data type.
|
The socket is an opaque data type.
|
||||||
*/
|
*/
|
||||||
virtual ArchSocket newSocket(AddressFamily, ESocketType) = 0;
|
virtual ArchSocket newSocket(AddressFamily, SocketType) = 0;
|
||||||
|
|
||||||
//! Copy a socket object
|
//! Copy a socket object
|
||||||
/*!
|
/*!
|
||||||
|
|
|
||||||
|
|
@ -95,10 +95,10 @@ void ArchNetworkBSD::init()
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchSocket ArchNetworkBSD::newSocket(AddressFamily family, ESocketType type)
|
ArchSocket ArchNetworkBSD::newSocket(AddressFamily family, SocketType type)
|
||||||
{
|
{
|
||||||
// create socket
|
// create socket
|
||||||
int fd = socket(s_family[static_cast<int>(family)], s_type[type], 0);
|
int fd = socket(s_family[static_cast<int>(family)], s_type[static_cast<int>(type)], 0);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
throwError(errno);
|
throwError(errno);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ public:
|
||||||
void init() override;
|
void init() override;
|
||||||
|
|
||||||
// IArchNetwork overrides
|
// IArchNetwork overrides
|
||||||
ArchSocket newSocket(AddressFamily, ESocketType) override;
|
ArchSocket newSocket(AddressFamily, SocketType) override;
|
||||||
ArchSocket copySocket(ArchSocket s) override;
|
ArchSocket copySocket(ArchSocket s) override;
|
||||||
void closeSocket(ArchSocket s) override;
|
void closeSocket(ArchSocket s) override;
|
||||||
void closeSocketForRead(ArchSocket s) override;
|
void closeSocketForRead(ArchSocket s) override;
|
||||||
|
|
|
||||||
|
|
@ -192,10 +192,10 @@ void ArchNetworkWinsock::initModule(HMODULE module)
|
||||||
s_networkModule = module;
|
s_networkModule = module;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchSocket ArchNetworkWinsock::newSocket(AddressFamily family, ESocketType type)
|
ArchSocket ArchNetworkWinsock::newSocket(AddressFamily family, SocketType type)
|
||||||
{
|
{
|
||||||
// create socket
|
// create socket
|
||||||
SOCKET fd = socket_winsock(s_family[static_cast<int>(family)], s_type[type], 0);
|
SOCKET fd = socket_winsock(s_family[static_cast<int>(family)], s_type[static_cast<int>(type)], 0);
|
||||||
if (fd == INVALID_SOCKET) {
|
if (fd == INVALID_SOCKET) {
|
||||||
throwError(getsockerror_winsock());
|
throwError(getsockerror_winsock());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ public:
|
||||||
void init() override;
|
void init() override;
|
||||||
|
|
||||||
// IArchNetwork overrides
|
// IArchNetwork overrides
|
||||||
ArchSocket newSocket(AddressFamily, ESocketType) override;
|
ArchSocket newSocket(AddressFamily, SocketType) override;
|
||||||
ArchSocket copySocket(ArchSocket s) override;
|
ArchSocket copySocket(ArchSocket s) override;
|
||||||
void closeSocket(ArchSocket s) override;
|
void closeSocket(ArchSocket s) override;
|
||||||
void closeSocketForRead(ArchSocket s) override;
|
void closeSocketForRead(ArchSocket s) override;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ TCPListenSocket::TCPListenSocket(
|
||||||
m_socketMultiplexer(socketMultiplexer)
|
m_socketMultiplexer(socketMultiplexer)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
m_socket = ARCH->newSocket(family, IArchNetwork::kSTREAM);
|
m_socket = ARCH->newSocket(family, IArchNetwork::SocketType::Stream);
|
||||||
} catch (XArchNetwork &e) {
|
} catch (XArchNetwork &e) {
|
||||||
throw XSocketCreate(e.what());
|
throw XSocketCreate(e.what());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ TCPSocket::TCPSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer,
|
||||||
m_socketMultiplexer(socketMultiplexer)
|
m_socketMultiplexer(socketMultiplexer)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
m_socket = ARCH->newSocket(family, IArchNetwork::kSTREAM);
|
m_socket = ARCH->newSocket(family, IArchNetwork::SocketType::Stream);
|
||||||
} catch (const XArchNetwork &e) {
|
} catch (const XArchNetwork &e) {
|
||||||
throw XSocketCreate(e.what());
|
throw XSocketCreate(e.what());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue