Description The getprotobynumber function returns the name associated with the protocol number defined by number.. getservbyname Syntax getservbynameservice, protocol; Description The
Trang 1Description
The getprotobynumber() function returns the name associated with the protocol number defined by number The name is retrieved from /etc/protocols
getservbyname()
Syntax
getservbyname(service, protocol);
Description
The getservbyname() function returns the port that corresponds to service and
protocol The services are retrieved from /etc/services file Valid protocols are specified as TCP or UDP
getservbyport()
Syntax
getservbyport(port, protocol);
Description
The getservbyport() function returns the service which corresponds to port and
protocol The services are retrieved from /etc/services Valid protocols are specified
as TCP or UDP
openlog()
Syntax
openlog(ident, option, facility);
Description
The openlog() function opens a connection to the system logger The string, ident,
is added to each entry sent to the system log Valid values for option are given in Table 7.3 and valid values for facility are given in Table 7.4 These values are also found in the manpage for syslog(3)
Note
Trang 2The option LOG_PID is the only valid option in the Windows environment
Table 7.3 Valid Values for option
LOG_PID Add the PID to each message
LOG_CONS If a message cannot be sent to the system log, send the message to
the system console
LOG_ODELAY Delay opening the log until the first call to syslog This is true by
default
LOG_NDELAY Open the log immediately Do not wait for the first call to syslog LOG_NOWAIT Do not wait for child processes The use of this flag is discouraged LOG_PERROR Log all messages to stderr
Note
LOG_USER is the only value for facility that is valid in the Windows environment
Table 7.4 Valid Values for facility
LOG_KERN Kernel messages
LOG_USER Generic user-level messages (default)
LOG_MAIL Mail subsystem
LOG_DAEMON Other system daemons
LOG_AUTH Security/authorization messages (deprecated; use LOG_AUTHPRIV
instead) LOG_SYSLOG Messages generated internally by syslogd
LOG_LPR Line printer subsystem
LOG_NEWS Usenet news subsystem
LOG_UUCP UUCP subsystem
LOG_CRON Clock daemon (cron and at)
LOG_AUTHPRIV Security/authorization messages
pfsockopen()
Syntax
pfsockopen(hostname, port, [errno], [errstr], [timeout]);
Trang 3Description
The pfsockopen() function is the persistent version of fsockopen() Both functions establish a socket connection as a file stream A TCP socket connection is established
to hostname and port The optional timeout parameter defines the timeout for the
connect() system call
The pfsockopen() function does not close the socket connection upon completion of
a read or write to the socket
If pfsockopen() is not successful, it will return false, 0 The optional variables errno and errstr will be set to indicate the system-level error that occurred If
pfsockopen() is successful, it will return a file pointer that can then be used by other file-related functions such as fputs(), fgets(), fclose(), and so on
set_socket_blocking()
Syntax
set_socket_blocking(socket descriptor, mode);
Description
The set_socket_blocking() function sets the blocking mode for the socket If mode
is false, 0, the socket descriptor will be switched to nonblocking mode Setting mode
to true, 1, will set the socket to blocking mode In nonblocking mode, calls that get information from the socket will return immediately with data that is in the input buffer In blocking mode, socket reads will halt execution until all the data available
on the socket is received
syslog()
Syntax
syslog(priority, message);
Description
The syslog() function adds message with priority to the system log Valid priorities are given in Table 7.5
Note
On Windows NT, the syslog service is provided through an emulator The messages are logged in the NT Event Log and can be viewed by using the Event Viewer
Trang 4Table 7.5 Priorities
LOG_EMERG This is a panic situation; the system is unstable The message may
be broadcast by the operating system to all users of the system This message is translated to a warning on Windows
LOG_ALERT This is a situation that requires action to be taken immediately It is
translated into an error on Windows
LOG_CRIT This is a critical condition that can by be caused by external or
hardware problems This is translated to a warning on Windows LOG_ERR These are general error conditions These are translated to warnings
on Windows
LOG_WARNING These are warnings, less severe than errors
LOG_NOTICE A notice is not an error, but is a significant condition requiring
attention This is translated to a warning on Windows
LOG_INFO Informational messages do not require any special action to be
taken
LOG_DEBUG These messages are only debug-level messages They are translated
to warnings on Windows
Session Handling
This section describes the session-handling functions that are included in the base PHP4 distribution These functions allow session variables to be established and tracked per visitor This functionality allows the user experience to vary depending
on permissions, user-defined options, or environment Sessions do not require variables to be stored in cookies, although it is possible, but rather session IDs are passed via the URL In either case, these variables are stored and retrieved on the server through these PHP functions
session_start()
Syntax
session_start();
Description
The session_start() function, which always returns true, allocates memory and establishes a session for the user
session_destroy()
Trang 5session_destroy();
Description
The session_destroy() function, which always returns true, terminates the session and destroys all the data associated with the user's session
session_name()
Syntax
session_name([name]);
Description
The session_name() function returns the name of the current session as a string If
name is specified, the name of the current session is changed to name
session_module_name
Syntax
session_module_name([module]);
Description
The session_module_name() function returns the name of the current session module as a string If module is specified, that module will be used
session_save_path()
Syntax
session_save_path([path]);
Description