MVI-ADMNET
♦
'C' Programmable
Application Development Function Library: ADMNET API
Ethernet Module
Page 40 of 90
ProSoft Technology, Inc.
December 13, 2006
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 open socket according to the name previously initialize, 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.
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 open socket.
SK_PROCESS_SOCKET
Open process is still in
SK_NOT_FOUND
API could not find an initialize socket with the name passed to the
function.
SK_TIMEOUT
Time out opening socket.
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);
}
See Also:
ADM_close_sk