| 50 | } |
| 51 | |
| 52 | int 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 | |
| 89 | int CNetworkClient::Recv(char *pLine, int MaxLength) |
| 90 | { |
nothing calls this directly
no test coverage detected