MCPcopy Create free account
hub / github.com/MaxBelkov/visualsyslog / Read

Method Read

sourcecommon/udp.cpp:332–382  ·  view source on GitHub ↗

---------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

330}
331//---------------------------------------------------------------------------
332bool TUDP::Read(void * data, int size, bool bPeek)
333{
334 WSAError = 0;
335 Error = 0;
336 bytes = 0;
337
338 if( !handle || size<=0 )
339 {
340 WSAError = MYERROR_UNKNOWNPARAMS;
341 Error = 1;
342 if( Exceptions ) throw 0;
343 return !Error;
344 }
345 // ������� �������� �������� ������
346 if( bBlockProtected )
347 {
348 DWORD bufsize;
349 if( ioctlsocket(handle, FIONREAD, &bufsize) == SOCKET_ERROR )
350 {
351 WSAError = WSAGetLastError();
352 Error = 2;
353 if( Exceptions ) throw 0;
354 return !Error;
355 }
356 if( bufsize < (DWORD)size )
357 {
358 Error = 3;
359 if( Exceptions ) throw 0;
360 return !Error;
361 }
362 }
363
364 bytes = recv(handle, (char *)data, size, bPeek ? MSG_PEEK : 0);
365 if( bytes == SOCKET_ERROR )
366 {
367 WSAError = WSAGetLastError();
368 Error = 4;
369 bytes = 0;
370 if( Exceptions ) throw 0;
371 return !Error;
372 }
373 if( bytes != size )
374 {
375 WSAError = WSAGetLastError();
376 Error = 5;
377 if( Exceptions ) throw 0;
378 return !Error;
379 }
380 InBytes += bytes;
381 return ! Error;
382}
383//---------------------------------------------------------------------------
384bool TUDP::WriteTo(void * data, int size, struct sockaddr * p)
385{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected