MCPcopy Create free account
hub / github.com/ddnet/ddnet / Send

Method Send

src/engine/shared/network_console_conn.cpp:157–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157int 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}

Callers

nothing calls this directly

Calls 3

str_lengthFunction · 0.85
net_tcp_sendFunction · 0.85
str_copyFunction · 0.50

Tested by

no test coverage detected