
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
Name of the socket that has been initialized and used to send data.
IP address that will be used to send data to.
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
API has successfully opened socket.
Open is still in process.
API could not find an initialized socket with the name passed to the
function.
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);
}
Komentarze do niniejszej Instrukcji