<< Previous | Index | Next >>

sock_write


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

Description

Writes up to len bytes from dp to socket s. This function busy waits until either the buffer is completely written or a socket error occurs. If sock_yield() has been called, the user-defined function that is passed to it will be called in a tight loop while sock_write() is busywaiting.

For UDP, sock_write() will send one (or more) records. For TCP, the new data may be transmitted 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, there is no guarantee of acceptance at the other end.

Starting with Dynamic C 7.05, this function is only valid for TCP sockets. For UDP sockets, use udp_send() or udp_sendto().

Parameters

s

Pointer to a socket.

dp

Pointer to a buffer.

len

Maximum number of bytes to write to the buffer.

Return value

Number of bytes written or -1 on an error.

Library

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

See also

sock_read, sock_fastwrite, sock_fastread, sockerr, sock_flush, sock_flushnext, udp_send, udp_sendto


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