<< Previous | Index | Next >>

sock_recv_init


int sock_recv_init( sock_type *s, void *space, word len );

Description

This function is not available starting with Dynamic C 7.05 (see Section 3.5).

The basic socket reading functions (sock_read(), sock_fastread(), etc.) are not adequate for all your UDP needs. The most basic limitation is their inability to treat UDP as a record service.

A record service must receive distinct datagrams and pass them to the user program as such. You must know the length of the received datagram and the sender (if you opened in broadcast mode). You may also receive the datagrams very quickly, so you must have a mechanism to buffer them.

Once a socket is opened with udp_open(), you can use sock_recv_init() to initialize that socket for sock_recv() and sock_recv_from(). Note that sock_recv() and related functions are incompatible with sock_read(), sock_fastread(), sock_gets() and sock_getc(). Once you have used sock_recv_init(), you can no longer use the older-style calls.

sock_recv_init() installs a large buffer area which gets segmented into smaller buffers. Whenever a UDP datagram arrives, DCRTCP.LIB stuffs that datagram into one of these new buffers. The new functions scan those buffers. You must select the size of the buffer you submit to sock_recv_init(); make it as large as possible, say 4K, 8K or 16K.

For a sample program, see Example using sock_recv() listed under sock_recv().

Parameters

s

Pointer to a UDP socket.

space

Buffer of temporary storage space to store newly received packets.

len

Size of the buffer.

Return value

0

Library

DCRTCP.LIB

See also

sock_recv_from, sock_recv


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