| 150 | } |
| 151 | |
| 152 | int CNetworkClient::Send(const char *pLine) |
| 153 | { |
| 154 | if(State() != NET_CONNSTATE_ONLINE) |
| 155 | return -1; |
| 156 | |
| 157 | char aBuf[1024]; |
| 158 | str_copy(aBuf, pLine, (int)(sizeof(aBuf))-2); |
| 159 | int Length = str_length(aBuf); |
| 160 | aBuf[Length] = m_aLineEnding[0]; |
| 161 | aBuf[Length+1] = m_aLineEnding[1]; |
| 162 | aBuf[Length+2] = m_aLineEnding[2]; |
| 163 | Length += 3; |
| 164 | const char *pData = aBuf; |
| 165 | |
| 166 | while(1) |
| 167 | { |
| 168 | int Send = net_tcp_send(m_Socket, pData, Length); |
| 169 | if(Send < 0) |
| 170 | { |
| 171 | m_State = NET_CONNSTATE_ERROR; |
| 172 | str_copy(m_aErrorString, "failed to send packet", sizeof(m_aErrorString)); |
| 173 | return -1; |
| 174 | } |
| 175 | |
| 176 | if(Send >= Length) |
| 177 | break; |
| 178 | |
| 179 | pData += Send; |
| 180 | Length -= Send; |
| 181 | } |
| 182 | |
| 183 | return 0; |
| 184 | } |
nothing calls this directly
no test coverage detected