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