Admnet api miscellaneous functions – ProSoft Technology MVI69-ADMNET User Manual

Page 74

Advertising
background image

Application Development Function Library - ADMNET API

MVI-ADMNET ♦ 'C' Programmable

Developer's Guide

'C' Programmable Application Development Module with Ethernet

Page 74 of 122

ProSoft Technology, Inc.

February 20, 2013

ADM_receive_buffered_UDP_sk


Syntax
int ADM_receive_buffered_UDP_sk(char *skName, char *holdRecPtr, int
*readLen, char *fromIP, int nBlock);

Parameters

skName

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

holdRecPtr

Pointer to a buffer to hold data that will be received by the API

readLen

Length of data received by the API

fromIP

Character array to hold client IP address

nBlock

Function will block on receive if nBlock > 0. If nBlock is 0, the function will
return

Description
This function is used to receive messages when ADM_init_UDP_buffer is used.
Received messages will be placed in the buffer pointed to by holdRecPtr. The
parameter readLen will be updated with the length of the received message. The
client’s IP address will be placed in fromIP.

Return Value

SK_SUCCESS

Message received if nBlock is non-zero. If nBlock is 0 then this
denotes a successful receive check which will result in a received
message if a message was available..

SK_NOT_FOUND

Socket could not be found.

SK_SOCKET_CLOSE

Socket is closed

Example

char sockName1[] = "ReceiveSocket";
char data[1024];
int length;
char fromIP[64];
unsigned long recvVal[10];

length = MAX_MESSAGE;
err = ADM_receive_buffered_UDP_sk(sockName1, data, &length, fromIP, 1);
if(length > 0)
{

recvVal[index++] = *(unsigned long *)data;

}
if(err < 0)
{

printf("got error\n");

}

Advertising