![]() |
|
| << Previous | Index | Next >> | |
| | |
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 usesock_recv_init()to initialize that socket forsock_recv()andsock_recv_from(). Note thatsock_recv()and related functions areincompatiblewithsock_read(),sock_fastread(),sock_gets()andsock_getc(). Once you have usedsock_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.LIBstuffs that datagram into one of these new buffers. The new functions scan those buffers. You must select the size of the buffer you submit tosock_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
0Library
DCRTCP.LIB
See also
| TCP/IP Manual Vol 1 |
<<Previous | Index | Next>> | rabbit.com |