| 304 | // ---------------------------------------------------------------------------------------- |
| 305 | |
| 306 | long connection:: |
| 307 | write ( |
| 308 | const char* buf, |
| 309 | long num |
| 310 | ) |
| 311 | { |
| 312 | const long old_num = num; |
| 313 | long status; |
| 314 | const long max_send_length = 1024*1024*100; |
| 315 | while (num > 0) |
| 316 | { |
| 317 | // Make sure to cap the max value num can take on so that if it is |
| 318 | // really large (it might be big on 64bit platforms) so that the OS |
| 319 | // can't possibly get upset about it being large. |
| 320 | const long length = std::min(max_send_length, num); |
| 321 | if ( (status = send(connection_socket,buf,length,0)) == SOCKET_ERROR) |
| 322 | { |
| 323 | if (sdo_called()) |
| 324 | return SHUTDOWN; |
| 325 | else |
| 326 | return OTHER_ERROR; |
| 327 | } |
| 328 | num -= status; |
| 329 | buf += status; |
| 330 | } |
| 331 | return old_num; |
| 332 | } |
| 333 | |
| 334 | // ---------------------------------------------------------------------------------------- |
| 335 | |