beautypg.com

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

Page 65

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 65 of 122

February 20, 2013

5.2

ADMNET API Initialize Functions

The following topics describe the ADMNET API Initialize functions.

ADM_init_socket

Syntax

int ADM_init_socket(int numSK, int portNum, int buffSize, char *name);

Parameters

numSK

Variable indicating how many sockets to use.

portNum

Port Number.

buffSize

The size of the buffer available in each socket.

name

The name of the socket.

Description
ADM_init_socket acquires access to the ADMNET API and dynamically
generates a set of sockets according to numSK and assigns portNum, buffSize,
then names each socket that the application will use in subsequent functions.
This function must be called before any of the other API functions can be used.

IMPORTANT After the API has been opened, ADM_Release_Sockets should always be called

before exiting the application.

Return Value

SK_SUCCESS

API has successfully initialized variables.

SK_PORT_NOT_ALLOW

API does not allow port number used.

SK_CANNOT_ALLOCATE_MEMORY

API cannot allocate memory.

Example

int numSK = 5;
int portNum = 5757;
int buffSize = 1000;

if(ADM_init_socket(numSK, portNum, buffSize, "ReceiveSK") != SK_SUCCESS)
{
printf("\nFailed to open ADM API... exiting program\n");
ADM_release_sockets();
}

See Also
ADM_release_sockets (page 68)