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

Method Send

server/src/network_client.cpp:152–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152int 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}

Callers

nothing calls this directly

Calls 3

str_copyFunction · 0.85
str_lengthFunction · 0.85
net_tcp_sendFunction · 0.85

Tested by

no test coverage detected