#include <sap_app.h>int SAPAdvertiseMyServer(uint16 ServerType, char ServerName, uint16 Socket, int Action);
This function does not use mapped memory, but sends a message via the protocol stack to the SAP daemon. The message is acknowledged by the SAP daemon to ensure that it was received.
Only the root user has permission to advertise using the SAP_ADVERTISE_FOREVER flag, and only root can unadvertise a server advertised with this flag.
When a server is advertised with the SAP_ADVERTISE_FOREVER flag, the server description is written to /etc/netware/sapouts. When NetWare® services are started, this file is read and the services are automatically re-advertised. Servers can be removed from sapouts only via a SAPAdvertiseMyServer call with the Action flag set to SAP_STOP_ADVERTISING.
To obtain a list of servers that are permanently advertised, use the SAPListPermanentServers(3sapd) function.
If SAP_ADVERTISE_FOREVER is set in Action, the SAP daemon places its own PID in the table.
The kill(2) system call with arguments ``(pid, 0)'' is used to determine if the process that made the SAPAdvertiseMyServer call is still active. As long as the process is active, the services for that process will be advertised. When the process terminates, the services for that process will be marked as HOPS = 16, or down.
The ServerType argument specifies the type of server to be advertised. See the table below for some common values.
Defined Constants for SAP daemon | Value | Server Type |
---|---|---|
FILE_SERVER_TYPE | 0x0004 | NetWare Server |
PRINT_SERVER_TYPE | 0x0047 | Print Server |
BTRIEVE_SERVER_TYPE | 0x004B | Btrieve Server |
ACCESS_SERVER_TYPE | 0x0098 | NetWare Access Server |
OLD_NVT_SERVER_TYPE | 0x009E | NVT over NVT protocol |
I386_SERVER_TYPE | 0x0107 | 386 NetWare (3.x) |
SPX_NVT_SERVER_TYPE | 0x0247 | NVT2 over SPX/SPXII protocol |
TIME_SYNC_SERVER_TYPE | 0x026B | Time Synchronization |
DIRECTORY_SERVER_TYPE | 0x0278 | Directory Server |
-------------------------------------------------------------------------------- | Defined Constants for SAP daemon| Value | Server Type | |---------------------------------|-----------------|---------------------------| | FILE_SERVER_TYPE | 0x0004 | NetWare Server | |---------------------------------|-----------------|---------------------------| | PRINT_SERVER_TYPE | 0x0047 | Print Server | |---------------------------------|-----------------|---------------------------| | BTRIEVE_SERVER_TYPE | 0x004B | Btrieve Server | |---------------------------------|-----------------|---------------------------| | ACCESS_SERVER_TYPE | 0x0098 | NetWare Access Server | |---------------------------------|-----------------|---------------------------| | OLD_NVT_SERVER_TYPE | 0x009E | NVT over NVT protocol | |---------------------------------|-----------------|---------------------------| | I386_SERVER_TYPE | 0x0107 | 386 NetWare (3.x) | |---------------------------------|-----------------|---------------------------| | SPX_NVT_SERVER_TYPE | 0x0247 | NVT2 over SPX/SPXII | | | | protocol | |---------------------------------|-----------------|---------------------------| | TIME_SYNC_SERVER_TYPE | 0x026B | Time Synchronization | |---------------------------------|-----------------|---------------------------| | DIRECTORY_SERVER_TYPE | 0x0278 | Directory Server | |---------------------------------|-----------------|---------------------------|The ServerName argument specifies the NULL-terminated name of the server to be advertised. If the name contained in ServerName is not less than SAP_MAX_SERVER_NAME_LENGTH, the request to advertise the server will be rejected.
The Socket argument is the socket number to which clients may make service requests. If Socket is zero (0), however, the effect of the SAPAdvertiseMyServer call is a notification to the network without providing real service.
The Action argument specifies the type of action the SAP daemon is to perform. Three values are valid:
Flag | Description |
---|---|
SAP_ADVERTISE | Advertise my server while my process lives or until it is discontinued |
SAP_ADVERTISE_FOREVER | Advertise my server until it is discontinued |
SAP_STOP_ADVERTISING | Discontinue advertising my server |
------------------------------------------------------------- | Flag | Description | |----------------------|-------------------------------------| | SAP_ADVERTISE | Advertise my server while my | | | process lives or until it is | | | discontinued | |----------------------|-------------------------------------| | SAP_ADVERTISE_FOREVER| Advertise my server until it is | | | discontinued | |----------------------|-------------------------------------| | SAP_STOP_ADVERTISING | Discontinue advertising my server | |----------------------|-------------------------------------|
strcpy (ServerName, "MY_SERVER"); Socket = 0; ServerType = UNIXWARE_TYPE; Action = SAP_ADVERTISE_FOREVER; ret=SAPAdvertiseMyServer(ServerType, ServerName, Socket, Action);