#include <C4NetIO.h>
Classes | |
struct | ConnectWait |
class | Peer |
class | Socket |
Public Types | |
typedef EndpointAddress | addr_t |
Public Member Functions | |
C4NetIOTCP () | |
~C4NetIOTCP () override | |
bool | Init (uint16_t iPort=addr_t::IPPORT_NONE) override |
virtual bool | InitBroadcast (addr_t *pBroadcastAddr) |
bool | Close () override |
virtual bool | CloseBroadcast () |
bool | Execute (int iMaxTime=TO_INF, pollfd *readyfds=nullptr) override |
std::unique_ptr< Socket > | Bind (const addr_t &addr) |
bool | Connect (const addr_t &addr, std::unique_ptr< Socket > socket) |
bool | Connect (const addr_t &addr) override |
bool | Close (const addr_t &addr) override |
bool | Send (const C4NetIOPacket &rPacket) override |
bool | Broadcast (const C4NetIOPacket &rPacket) override |
bool | SetBroadcast (const addr_t &addr, bool fSet=true) override |
virtual void | UnBlock () |
void | GetFDs (std::vector< struct pollfd > &FDs) override |
bool | GetStatistic (int *pBroadcastRate) override |
bool | GetConnStatistic (const addr_t &addr, int *pIRate, int *pORate, int *pLoss) override |
void | ClearStatistic () override |
void | SetCallback (CBClass *pnCallback) override |
bool | IsNotify () override |
virtual bool | Send (const class C4NetIOPacket &rPacket)=0 |
virtual bool | Broadcast (const class C4NetIOPacket &rPacket)=0 |
virtual const char * | GetError () const |
void | ResetError () |
bool | ExecuteUntil (int iTimeout=-1) |
virtual C4TimeMilliseconds | GetNextTick (C4TimeMilliseconds tNow) |
bool | IsSignaled () |
virtual bool | IsLowPriority () |
virtual uint32_t | TimerInterval () |
Static Public Member Functions | |
static std::vector< HostAddress > | GetLocalAddresses () |
Static Public Attributes | |
static const int | TO_INF = -1 |
Protected Member Functions | |
virtual void | PackPacket (const C4NetIOPacket &rPacket, StdBuf &rOutBuf) |
virtual size_t | UnpackPacket (const StdBuf &rInBuf, const C4NetIO::addr_t &Addr) |
bool | Listen (uint16_t inListenPort) |
SOCKET | CreateSocket (addr_t::AddressFamily family) |
bool | Connect (const addr_t &addr, SOCKET nsock) |
Peer * | Accept (SOCKET nsock=INVALID_SOCKET, const addr_t &ConnectAddr=addr_t()) |
Peer * | GetPeer (const addr_t &addr) |
void | OnShareFree (CStdCSecEx *pCSec) override |
void | AddConnectWait (SOCKET sock, const addr_t &addr) |
ConnectWait * | GetConnectWait (const addr_t &addr) |
void | ClearConnectWaits () |
bool | InitIPv6Socket (SOCKET socket) |
void | SetError (const char *strnError, bool fSockErr=false) |
void | Changed () |
Protected Attributes | |
Peer * | pPeerList {nullptr} |
struct C4NetIOTCP::ConnectWait | nullptr |
CStdCSecEx | PeerListCSec |
CStdCSec | PeerListAddCSec |
bool | fInit {false} |
uint16_t | iListenPort |
SOCKET | lsock |
int | Pipe [2] |
StdCopyStrBuf | Error |
Friends | |
class | Peer |
struct C4NetIOTCP::ConnectWait |
|
inherited |
C4NetIOTCP::C4NetIOTCP | ( | ) |
Definition at line 799 of file C4NetIO.cpp.
|
override |
Definition at line 806 of file C4NetIO.cpp.
References Close().
|
protected |
Definition at line 1427 of file C4NetIO.cpp.
References StdSchedulerProc::Changed(), C4NetIO::EndpointAddress::Clear(), CStdLock::Clear(), C4NetIOTCP::Peer::Close(), closesocket, C4NetIO::HostAddress::GetAddrLen(), C4NetIO::HostAddress::GetFamily(), INVALID_SOCKET, ioctlsocket, lsock, C4NetIOTCP::Peer::Next, C4NetIO::CBClass::OnConn(), Peer, PeerListAddCSec, PeerListCSec, pPeerList, C4NetIO::SetError(), SOCK_CLOEXEC, SOCKET_ERROR, and C4NetIO::HostAddress::UnknownFamily.
Referenced by Execute().
Definition at line 1651 of file C4NetIO.cpp.
References C4NetIOTCP::ConnectWait::addr, StdSchedulerProc::Changed(), C4NetIOTCP::ConnectWait::Next, PeerListAddCSec, PeerListCSec, C4NetIOTCP::ConnectWait::sock, and UnBlock().
Referenced by Connect().
std::unique_ptr< C4NetIOTCP::Socket > C4NetIOTCP::Bind | ( | const addr_t & | addr | ) |
Definition at line 1192 of file C4NetIO.cpp.
References closesocket, CreateSocket(), C4NetIO::HostAddress::GetAddrLen(), C4NetIO::HostAddress::GetFamily(), INVALID_SOCKET, C4NetIO::SetError(), SOCKET, and SOCKET_ERROR.
|
override |
Definition at line 1332 of file C4NetIO.cpp.
References C4NetIOPacket::getRef(), C4NetIOTCP::Peer::Next, PeerListCSec, pPeerList, and Send().
|
pure virtualinherited |
|
protectedinherited |
Definition at line 108 of file StdScheduler.cpp.
References s.
Referenced by Accept(), AddConnectWait(), C4NetIOUDP::AddPeer(), Listen(), and CStdTimerProc::SetDelay().
|
protected |
Definition at line 1677 of file C4NetIO.cpp.
References closesocket, C4NetIOTCP::ConnectWait::Next, and PeerListCSec.
Referenced by Close().
|
overridevirtual |
Implements C4NetIO.
Definition at line 1419 of file C4NetIO.cpp.
References C4NetIOTCP::Peer::Next, PeerListCSec, and pPeerList.
|
overridevirtual |
Implements C4NetIO.
Reimplemented in C4Network2IRCClient, C4AulDebug, C4Network2IRCClient, and C4Network2IRCClient.
Definition at line 857 of file C4NetIO.cpp.
References ClearConnectWaits(), closesocket, fInit, INVALID_SOCKET, lsock, C4NetIOTCP::Peer::Next, C4NetIO::CBClass::OnDisconn(), PeerListCSec, Pipe, pPeerList, and C4NetIO::ResetError().
Referenced by C4Network2RefServer::Clear(), C4Network2IRCClient::Close(), C4AulDebug::Close(), Init(), ~C4NetIOTCP(), and C4NetIOTCP::Peer::~Peer().
|
overridevirtual |
Implements C4NetIO.
Reimplemented in C4AulDebug.
Definition at line 1279 of file C4NetIO.cpp.
References C4NetIOTCP::ConnectWait::addr, C4NetIOTCP::Peer::Close(), closesocket, C4NetIOTCP::Peer::GetAddr(), GetConnectWait(), GetPeer(), C4NetIO::CBClass::OnDisconn(), PeerListCSec, and C4NetIOTCP::ConnectWait::sock.
|
virtual |
Definition at line 905 of file C4NetIO.cpp.
|
overridevirtual |
Implements C4NetIO.
Definition at line 1214 of file C4NetIO.cpp.
References Connect(), CreateSocket(), C4NetIO::HostAddress::GetFamily(), INVALID_SOCKET, and SOCKET.
Definition at line 1223 of file C4NetIO.cpp.
References AddConnectWait(), closesocket, C4NetIO::HostAddress::GetAddrLen(), HaveWouldBlockError(), ioctlsocket, C4NetIO::SetError(), and SOCKET_ERROR.
Definition at line 1207 of file C4NetIO.cpp.
References INVALID_SOCKET, and SOCKET.
Referenced by C4Network2IOConnection::Connect(), Connect(), and C4Network2IRCClient::Connect().
|
protected |
Definition at line 1172 of file C4NetIO.cpp.
References closesocket, C4NetIO::InitIPv6Socket(), INVALID_SOCKET, C4NetIO::HostAddress::IPv6, C4NetIO::SetError(), SOCK_CLOEXEC, and SOCKET.
Referenced by Bind(), and Connect().
Implements C4NetIO.
Definition at line 919 of file C4NetIO.cpp.
References Accept(), fInit, GetFDs(), GetSocketErrorMsg(), HaveWouldBlockError(), iListenPort, INFINITE, INVALID_SOCKET, ioctlsocket, Listen(), lsock, C4NetIOTCP::Peer::Next, C4NetIO::CBClass::OnDisconn(), PeerListCSec, Pipe, pPeerList, ResetSocketError(), C4NetIO::SetError(), SOCKET, SOCKET_ERROR, and C4NetIO::TO_INF.
Referenced by C4AulDebug::DebugStep().
|
inherited |
Definition at line 33 of file StdScheduler.cpp.
References StdSchedulerProc::Execute(), and C4TimeMilliseconds::Now().
Referenced by main().
|
protected |
Definition at line 1667 of file C4NetIO.cpp.
References C4NetIOTCP::ConnectWait::Next, and PeerListCSec.
Referenced by Close().
|
overridevirtual |
Implements C4NetIO.
Definition at line 1406 of file C4NetIO.cpp.
References C4NetIOTCP::Peer::GetIRate(), C4NetIOTCP::Peer::GetORate(), GetPeer(), C4NetIOTCP::Peer::Open(), and PeerListCSec.
|
inlinevirtualinherited |
Definition at line 286 of file C4NetIO.h.
References C4NetIO::Error, and StdStrBuf::getData().
Referenced by C4Network2IO::ConnectWithSocket(), C4NetIOUDP::DoLoopbackTest(), C4StartupNetDlg::DoRefresh(), C4Network2IO::Init(), C4NetIOUDP::InitBroadcast(), main(), MyCBClass::OnConn(), C4ChatControl::OnConnectBtn(), MyCBClass::OnPacket(), C4ChatControl::ProcessInput(), and C4Network2IOConnection::Send().
|
overridevirtual |
Reimplemented from StdSchedulerProc.
Definition at line 1364 of file C4NetIO.cpp.
References INVALID_SOCKET, lsock, C4NetIOTCP::Peer::Next, C4NetIOTCP::ConnectWait::Next, PeerListCSec, Pipe, and pPeerList.
Referenced by Execute().
|
staticinherited |
Definition at line 631 of file C4NetIO.cpp.
References C4NetIO::HostAddress::IsLoopback(), and C4NetIO::HostAddress::SetHost().
Referenced by C4Network2Client::AddLocalAddrs(), and C4NetIOUDP::InitBroadcast().
|
virtualinherited |
Reimplemented in CStdTimerProc, C4Network2IO, C4NetIOUDP, and C4HTTPClient.
Definition at line 115 of file StdScheduler.cpp.
References C4TimeMilliseconds::PositiveInfinity.
|
protected |
Definition at line 1593 of file C4NetIO.cpp.
References C4NetIOTCP::Peer::Next, PeerListCSec, and pPeerList.
Referenced by Close(), GetConnStatistic(), Send(), and SetBroadcast().
|
overridevirtual |
Implements C4NetIO.
Definition at line 1399 of file C4NetIO.cpp.
|
overridevirtual |
Implements C4NetIO.
Reimplemented in C4AulDebug.
Definition at line 811 of file C4NetIO.cpp.
References Close(), fInit, C4NetIO::EndpointAddress::IPPORT_NONE, Listen(), Pipe, and C4NetIO::SetError().
Referenced by C4Network2IRCClient::Connect(), C4Network2IO::Init(), and C4AulDebug::Init().
|
virtual |
Definition at line 851 of file C4NetIO.cpp.
|
protectedinherited |
Definition at line 730 of file C4NetIO.cpp.
References C4NetIO::SetError(), and SOCKET_ERROR.
Referenced by CreateSocket(), C4NetIOSimpleUDP::Init(), and Listen().
|
inlinevirtualinherited |
Definition at line 82 of file StdScheduler.h.
|
inlineoverridevirtualinherited |
|
inherited |
|
protected |
Definition at line 1538 of file C4NetIO.cpp.
References C4NetIO::HostAddress::Any, StdSchedulerProc::Changed(), closesocket, C4NetIO::HostAddress::GetAddrLen(), iListenPort, C4NetIO::InitIPv6Socket(), INVALID_SOCKET, C4NetIO::EndpointAddress::IPPORT_NONE, lsock, C4NetIO::SetError(), C4NetIO::EndpointAddress::SetPort(), SOCK_CLOEXEC, and SOCKET_ERROR.
Referenced by Execute(), and Init().
|
overrideprotectedvirtual |
Implements CStdCSecExCallback.
Definition at line 1603 of file C4NetIO.cpp.
References C4NetIOTCP::Peer::Next, C4NetIOTCP::ConnectWait::Next, C4NetIOTCP::Peer::Open(), PeerListCSec, pPeerList, and C4NetIOTCP::ConnectWait::sock.
|
protectedvirtual |
Reimplemented in C4Network2RefServer.
Definition at line 1688 of file C4NetIO.cpp.
References StdBuf::getSize(), StdBuf::Grow(), iSize, and StdBuf::Write().
|
inlineinherited |
Definition at line 287 of file C4NetIO.h.
References StdStrBuf::Clear(), and C4NetIO::Error.
Referenced by C4NetIO::C4NetIO(), Close(), C4NetIOSimpleUDP::Close(), C4NetIOUDP::CloseBroadcast(), C4Network2IO::ConnectWithSocket(), C4NetIOSimpleUDP::Execute(), C4NetIOUDP::Execute(), C4NetIOSimpleUDP::Init(), C4NetIOSimpleUDP::InitBroadcast(), C4NetIOUDP::InitBroadcast(), C4NetIOSimpleUDP::Send(), and C4Network2IOConnection::Send().
|
override |
Definition at line 1310 of file C4NetIO.cpp.
References C4NetIOPacket::getAddr(), GetPeer(), PeerListCSec, and C4NetIOTCP::Peer::Send().
Referenced by Broadcast(), C4NetIOTCP::Peer::Send(), and C4Network2IRCClient::Send().
|
pure virtualinherited |
Referenced by main(), MyCBClass::OnConn(), MyCBClass::OnPacket(), C4Network2IOConnection::Send(), and C4Network2IO::SendPuncherPacket().
|
overridevirtual |
Implements C4NetIO.
Definition at line 1321 of file C4NetIO.cpp.
References GetPeer(), PeerListCSec, and C4NetIOTCP::Peer::SetBroadcast().
|
inlineoverridevirtual |
Implements C4NetIO.
Definition at line 505 of file C4NetIO.h.
Referenced by C4Network2IRCClient::Connect(), and C4AulDebug::Init().
|
protectedinherited |
Definition at line 750 of file C4NetIO.cpp.
References StdStrBuf::Copy(), C4NetIO::Error, StdStrBuf::Format(), GetSocketErrorMsg(), and HaveSocketError().
Referenced by Accept(), Bind(), C4NetIOSimpleUDP::CloseBroadcast(), Connect(), C4Network2IRCClient::Connect(), CreateSocket(), C4NetIOUDP::DoLoopbackTest(), C4NetIOSimpleUDP::Execute(), C4NetIOUDP::Execute(), Execute(), Init(), C4NetIOSimpleUDP::Init(), C4NetIOSimpleUDP::InitBroadcast(), C4NetIOUDP::InitBroadcast(), C4NetIO::InitIPv6Socket(), C4Network2IRCClient::Join(), Listen(), C4NetIOSimpleUDP::Send(), C4Network2IRCClient::Send(), UnBlock(), and C4NetIOSimpleUDP::UnBlock().
|
inlinevirtualinherited |
|
virtual |
Definition at line 1343 of file C4NetIO.cpp.
References Pipe, and C4NetIO::SetError().
Referenced by AddConnectWait().
|
protectedvirtual |
Reimplemented in C4Network2RefServer.
Definition at line 1705 of file C4NetIO.cpp.
References StdBuf::getPart(), StdBuf::getSize(), and C4NetIO::CBClass::OnPacket().
|
protectedinherited |
Definition at line 283 of file C4NetIO.h.
Referenced by C4NetIO::GetError(), C4NetIO::ResetError(), and C4NetIO::SetError().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Definition at line 471 of file C4NetIO.h.
Referenced by Accept(), and AddConnectWait().
|
protected |
Definition at line 470 of file C4NetIO.h.
Referenced by Accept(), AddConnectWait(), Broadcast(), ClearConnectWaits(), ClearStatistic(), Close(), Execute(), GetConnectWait(), GetConnStatistic(), GetFDs(), GetPeer(), OnShareFree(), Send(), and SetBroadcast().
|
protected |
Definition at line 458 of file C4NetIO.h.
Referenced by Accept(), Broadcast(), ClearStatistic(), Close(), Execute(), GetFDs(), GetPeer(), and OnShareFree().
|
staticinherited |
Definition at line 66 of file C4NetIO.h.
Referenced by C4NetIOUDP::Execute(), Execute(), C4NetIOUDP::Peer::OnConn(), C4NetIOUDP::Peer::OnTimeout(), and C4NetIOUDP::Peer::SetTimeout().