<< Previous | Index | Next >>

sock_fastwrite


int sock_fastwrite( tcp_Socket *s, byte *dp, int len );

Description

Writes up to len bytes from dp to socket s. This function writes as many bytes as possible to the socket and returns that number of bytes. Starting with Dynamic C 7.05, this function is only valid for TCP sockets. For UDP sockets, use udp_send() or udp_sendto().

When using a UDP socket prior to DC 7.05, sock_fastwrite() will send one record if


len <= ETH_MTU - 20 - 8

ETH_MTU is the Ethernet Maximum Transmission Unit; 20 is the IP header size and 8 is the UDP header size. By default, this is 572 bytes. If len is greater than this number, then the function does not send the data and returns -1. Otherwise, the UDP datagram would need to be fragmented.

For TCP, the new data is queued for sending and sock_fastwrite() returns the number of bytes that will be sent. The data may be transmitted immediately if enough data is in the buffer, or sufficient time has expired, or the user has explicitly used sock_flushnext() to indicate this data should be flushed immediately. In either case, no guarantee of acceptance at the other end is possible.

Parameters

s

Pointer to a socket.

dp

Buffer to be written.

len

Maximum number of bytes to write to the socket.

Return value

0: Success, number of bytes written.
-1: Error.

Library

TCP.LIB (Prior to DC 7.05, this was DCRTCP.LIB)

See Also

sock_write, sock_fastread, sock_read, sockerr, sock_flush, sock_flushnext, udp_send, udp_sendto, sock_xfastwrite


TCP/IP Manual
Vol 1
<<Previous | Index | Next>> rabbit.com