------------------------------------------------------------------------------
| 546 | |
| 547 | //------------------------------------------------------------------------------ |
| 548 | int vtkSocket::Send(const void* data, int length) |
| 549 | { |
| 550 | #ifndef VTK_SOCKET_FAKE_API |
| 551 | if (!this->GetConnected()) |
| 552 | { |
| 553 | vtkErrorMacro("Not connected."); |
| 554 | return 0; |
| 555 | } |
| 556 | if (length == 0) |
| 557 | { |
| 558 | // nothing to send. |
| 559 | return 1; |
| 560 | } |
| 561 | const char* buffer = reinterpret_cast<const char*>(data); |
| 562 | int total = 0; |
| 563 | do |
| 564 | { |
| 565 | int flags = 0; |
| 566 | int nSent; |
| 567 | vtkRestartInterruptedSystemCallMacro( |
| 568 | send(this->SocketDescriptor, buffer + total, length - total, flags), nSent); |
| 569 | if (nSent == vtkSocketErrorReturnMacro) |
| 570 | { |
| 571 | vtkSocketErrorMacro(vtkErrnoMacro, "Socket error in call to send."); |
| 572 | return 0; |
| 573 | } |
| 574 | total += nSent; |
| 575 | } while (total < length); |
| 576 | |
| 577 | return 1; |
| 578 | #else |
| 579 | static_cast<void>(data); |
| 580 | static_cast<void>(length); |
| 581 | return 0; |
| 582 | #endif |
| 583 | } |
| 584 | |
| 585 | //------------------------------------------------------------------------------ |
| 586 | int vtkSocket::Receive(void* data, int length, int readFully /*=1*/) |