ProSoft Technology MVI69-ADMNET User Manual
Page 66
![background image](https://www.manualsdir.com/files/866089/content/doc066.png)
Application Development Function Library - ADMNET API
MVI-ADMNET ♦ 'C' Programmable
Developer's Guide
'C' Programmable Application Development Module with Ethernet
Page 66 of 122
ProSoft Technology, Inc.
February 20, 2013
ADM_open_sk
Syntax
int ADM_open_sk(char *skName, char *ServerIPAddress, int protocol);
Parameters
skName
Name of the socket that has been initialized and used to send data.
ServerIPAddress
IP address that will be used to send data to.
protocol
Specified protocol to send over Ethernet (USE_TCP or USE_UDP).
Description
ADM_open_sk opens a socket according to the name previously initialized,
skName, with ADM_init_socket given, and assigns IP address, ServerIPAddress
for send function with specific protocol, either UDP or TCP. ADM_init_socket
must be used before this function. Returns SK_TIMEOUT if no connection is
made within 30 seconds.
IMPORTANT: After the API has been opened, ADM_close_sk should always be called for closing
the socket. 0.0.0.0 passes as ServerIPAddress to open socket as a server to listen to a message
from client.
Return Value
SK_SUCCESS
API has successfully opened socket.
SK_PROCESS_SOCKET
Open is still in process.
SK_NOT_FOUND
API could not find an initialized socket with the name passed to the
function.
SK_TIMEOUT
Time out opening socket.
SK_OPEN_FAIL
Socket could not be opened.
Example
char sockName1[ ] = "SendSocket";
int buffSize1 = 4096;
int port_1 = 6565;
int numSocket1 = 1;
int result;
sock_init(); //initialize the socket interface
ADM_init_socket(numSocket1, port_1, buffSize1, sockName1);
while ((result = ADM_open_sk(sockName1, "0.0.0.0",
USE_TCP))==SK_PROCESS_SOCKET);
if (result==SK_SUCCESS)
{
printf("successfully Opened a connection!\n");
} else {
printf("Error Opening a connection! %d\n", result);
}