| 368 | // ---------------------------------------------------------------------------------------- |
| 369 | |
| 370 | long connection:: |
| 371 | write ( |
| 372 | const char* buf, |
| 373 | long num |
| 374 | ) |
| 375 | { |
| 376 | const long old_num = num; |
| 377 | long status; |
| 378 | const long max_send_length = 1024*1024*100; |
| 379 | while (num > 0) |
| 380 | { |
| 381 | // Make sure to cap the max value num can take on so that if it is |
| 382 | // really large (it might be big on 64bit platforms) so that the OS |
| 383 | // can't possibly get upset about it being large. |
| 384 | const long length = std::min(max_send_length, num); |
| 385 | if ( (status = ::send(connection_socket,buf,length,0)) <=0) |
| 386 | { |
| 387 | // if send was interupted by a signal then restart it |
| 388 | if (errno == EINTR) |
| 389 | { |
| 390 | continue; |
| 391 | } |
| 392 | else |
| 393 | { |
| 394 | // check if shutdown or shutdown_outgoing have been called |
| 395 | if (sdo_called()) |
| 396 | return SHUTDOWN; |
| 397 | else |
| 398 | return OTHER_ERROR; |
| 399 | } |
| 400 | } |
| 401 | num -= status; |
| 402 | buf += status; |
| 403 | } |
| 404 | return old_num; |
| 405 | } |
| 406 | |
| 407 | // ---------------------------------------------------------------------------------------- |
| 408 | |