GetServerInfo
Listen for server information via TCP/IP.
Short Name
GetServerInfo()
Type
Low-Level function
Declaration
NINT GetServerInfo(pTEXT buffer, NINT bufsiz)
Description
On the client side, GetServerInfo() listens on the default port and stores the broadcast string in buffer. If the default port is not used, change the value for the client by altering the following define in ctcomm.h:
#define ctsrvBROADCAST_PORT 5595
By default, GetServerInfo() times out after 90 seconds. Adjust this timeout value by setting the following define in ctoptn.h or ctree.mak:
#define myWAIT_SEC 90
Return
This routine returns NO_ERROR (0) if it executed properly, -1 if the buffer was smaller than the string it received, or the value of the system-level errno if an error occurred. Check your compiler’s documentation for valid errno values.
Example
TEXT info_buf[128];
NINT retval;
pTEXT wptr;
ctrt_printf("Checking for Broadcast Servers .........\n");
if (retval = GetServerInfo(info_buf, (NINT)sizeof(info_buf))) {
ctrt_printf("Error getting available servers [%ld] \n",
(LONG)retval);
}
if ((ctrt_strlen(info_buf) < 1) && !retval) {
printf("No Broadcasting Servers Available \n");
} else {
if ((wptr = strchr(info_buf,'|')))
*wptr = '@';
if ((wptr = strchr(info_buf,'|')))
*wptr = '\0';
ctrt_printf("We will attempt a connection to [%s] on port
[%s].\n", info_buf, ++wptr);
*svn = info_buf;
}
See also