Network: First commit
Former-commit-id: ec8697acc51569f5043e4f70e4cf42f1c5dc487c
This commit is contained in:
66
include/Nazara/Network/UdpSocket.inl
Normal file
66
include/Nazara/Network/UdpSocket.inl
Normal file
@@ -0,0 +1,66 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Network module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Network/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline UdpSocket::UdpSocket() :
|
||||
AbstractSocket(SocketType_UDP)
|
||||
{
|
||||
}
|
||||
|
||||
inline UdpSocket::UdpSocket(NetProtocol protocol) :
|
||||
UdpSocket()
|
||||
{
|
||||
Create(protocol);
|
||||
}
|
||||
|
||||
inline UdpSocket::UdpSocket(UdpSocket&& udpSocket) :
|
||||
AbstractSocket(std::move(udpSocket)),
|
||||
m_boundAddress(std::move(udpSocket.m_boundAddress)),
|
||||
m_state(udpSocket.m_state)
|
||||
{
|
||||
}
|
||||
|
||||
inline SocketState UdpSocket::Bind(UInt16 port)
|
||||
{
|
||||
IpAddress any;
|
||||
switch (m_protocol)
|
||||
{
|
||||
case NetProtocol_IPv4:
|
||||
any = IpAddress::AnyIpV4;
|
||||
break;
|
||||
|
||||
case NetProtocol_IPv6:
|
||||
any = IpAddress::AnyIpV6;
|
||||
break;
|
||||
}
|
||||
|
||||
any.SetPort(port);
|
||||
return Bind(any);
|
||||
}
|
||||
|
||||
bool UdpSocket::Create(NetProtocol protocol)
|
||||
{
|
||||
return Open(protocol);
|
||||
}
|
||||
|
||||
inline IpAddress UdpSocket::GetBoundAddress() const
|
||||
{
|
||||
return m_boundAddress;
|
||||
}
|
||||
|
||||
inline UInt16 UdpSocket::GetBoundPort() const
|
||||
{
|
||||
return m_boundAddress.GetPort();
|
||||
}
|
||||
|
||||
inline SocketState UdpSocket::GetState() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Network/DebugOff.hpp>
|
||||
Reference in New Issue
Block a user