---------------------------------------------------------------------------
| 330 | } |
| 331 | //--------------------------------------------------------------------------- |
| 332 | bool 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 | //--------------------------------------------------------------------------- |
| 384 | bool TUDP::WriteTo(void * data, int size, struct sockaddr * p) |
| 385 | { |
nothing calls this directly
no outgoing calls
no test coverage detected