beautypg.com

ProSoft Technology MVI69-ADMNET User Manual

Page 67

background image

MVI-ADMNET ♦ 'C' Programmable

Application Development Function Library - ADMNET API

'C' Programmable Application Development Module with Ethernet

Developer's Guide

ProSoft Technology, Inc.

Page 67 of 122

February 20, 2013

ADM_init_UDP_buffer


Syntax
int ADM_init_UDP_buffer(char *skName, char **buffer, int maxLength);

Parameters

skName

Name of the socket that has been initialized and used to receive data

buffer

Pointer to a buffer to hold received messages

maxlength

Maximum length of each message in the buffer

Description
ADM_init_UDP_buffer attaches a user supplied buffer to the UDP socket for
storing the received messages. Since the buffer is user supplied, the user can
adjust the size to suit the application.

Return Value

SK_SUCCESS

Buffer has been attached to UDP socket
successfully.

SK_NOT_FOUND

Socket could not be found.

SK_CANNOT_ALLOCATE_MEMORY

API cannot allocate memory.

Example

char sockName1[] = "ReceiveSocket";

#define BIG_BUFFER_SIZE_CYCLIC 32767 /* each rx buff is 1500 bytes of
data and 12 bytes header for buffer = 12 buffers */

char far bigbuff0[BIG_BUFFER_SIZE_CYCLIC]; //buffer to store received
UDP datagrams

if(ADM_init_UDP_buffer(sockName1, (char**)&bigbuff0[0],
BIG_BUFFER_SIZE_CYCLIC))
{

printf("\nCould not enable large buffers for server!\n");

sock_close(sockName1);

return;

}

printf("listen for datagrams\n");