GetServerInfoXtd
Listen for server information via TCP/IP, Extended Version.
Short Name
GetServerInfoXtd()
Type
Low-Level function
Declaration
NINT GetServerInfoXtd(pTEXT buffer, NINT bufsiz, UCOUNT port, LONG sec)
Description
GetServerInfoXtd() listens for a broadcasting FairCom Server on TCP/IP port port for sec seconds before timing out. The port value should match the TCP/IP port set in the Server BROADCAST_PORT keyword. A negative sec defaults to 90 seconds. If a broadcast is received, up to bufsiz bytes are stored at buffer.
Return
This routine returns NO_ERROR (0) if 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;
UCOUNT port = myBroadcastPort;
LONG sec = myBroadcastTimout;
ctrt_printf("Checking for Broadcast Servers .........\n");
if (retval = GetServerInfoXtd(info_buf, (NINT) sizeof(info_buf), port, sec)) {
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
GetServerInfo()