MCPcopy Create free account
hub / github.com/cppla/ServerStatus / Update

Method Update

server/src/network_client.cpp:52–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52int CNetworkClient::Update()
53{
54 if(State() == NET_CONNSTATE_ONLINE)
55 {
56 if((int)(sizeof(m_aBuffer)) <= m_BufferOffset)
57 {
58 m_State = NET_CONNSTATE_ERROR;
59 str_copy(m_aErrorString, "too weak connection (out of buffer)", sizeof(m_aErrorString));
60 return -1;
61 }
62
63 int Bytes = net_tcp_recv(m_Socket, m_aBuffer+m_BufferOffset, (int)(sizeof(m_aBuffer))-m_BufferOffset);
64
65 if(Bytes > 0)
66 {
67 m_BufferOffset += Bytes;
68 }
69 else if(Bytes < 0)
70 {
71 if(net_would_block()) // no data received
72 return 0;
73
74 m_State = NET_CONNSTATE_ERROR; // error
75 str_copy(m_aErrorString, "connection failure", sizeof(m_aErrorString));
76 return -1;
77 }
78 else
79 {
80 m_State = NET_CONNSTATE_ERROR;
81 str_copy(m_aErrorString, "remote end closed the connection", sizeof(m_aErrorString));
82 return -1;
83 }
84 }
85
86 return 0;
87}
88
89int CNetworkClient::Recv(char *pLine, int MaxLength)
90{

Callers

nothing calls this directly

Calls 3

str_copyFunction · 0.85
net_tcp_recvFunction · 0.85
net_would_blockFunction · 0.85

Tested by

no test coverage detected