MCPcopy Create free account
hub / github.com/WheretIB/nullc / SocketSend

Function SocketSend

SuperCalc.cpp:202–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200 SOCKET sck;
201
202 int SocketSend(SOCKET sck, char* source, size_t size, int timeOut)
203 {
204 TIMEVAL tv = { timeOut, 0 };
205 fd_set fdSet;
206 FD_ZERO(&fdSet);
207 FD_SET(sck, &fdSet);
208
209 int active = select(0, NULL, &fdSet, NULL, &tv);
210 if(active == SOCKET_ERROR)
211 {
212 printf("select failed\n");
213 return -1;
214 }
215 if(!FD_ISSET(sck, &fdSet))
216 {
217 printf("!FD_ISSET\n");
218 return 0;
219 }
220
221 int allSize = (int)size;
222 while(size)
223 {
224 int bytesSent;
225 if((bytesSent = send(sck, source + (allSize - size), (int)size, 0)) == SOCKET_ERROR || bytesSent == 0)
226 {
227 printf("send failed\n");
228 return -1;
229 }
230 size -= bytesSent;
231 if(size)
232 printf("Partial send\n");
233 }
234 return allSize;
235 }
236 int SocketReceive(SOCKET sck, char* destination, size_t size, int timeOut)
237 {
238 TIMEVAL tv = { timeOut, 0 };

Callers 2

PipeSendRequestFunction · 0.70
BroadcastThreadFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected