HomeContentsContents
bind_port() close_connection() connection() cwrite()
cwritef() open_connection() reassign_connection() unbind_port()

bind_port()

INTEGER bind_port(INTEGER port[, STRING addr])

This function binds a network port to the current object. If successful, the current object will receive connections on the port. The first argument specifies the port to bind to. Positive port numbers represent the TCP protocol. Negative port numbers represent the UDP protocol. The second optional argument is the address to bind to, which must be a standard IP address (not an internet domain name). This is usually not required, but can be useful if multiple addresses exist on the system and only one must be bound.

If the port is pre-bound but the address does not match up, the error ~preaddr may be thrown. If the port is pre-bound and the protocols do not match, the error ~pretype is thrown. If the given address is not a valid IP address the error ~address is thrown. Other errors may be thrown (such as ~socket or ~bind) if other problems arise.

Top

close_connection()

INTEGER close_connection()

This function closes the connection on the current object. If there is no connection on the current object, 0 (zero) is returned.

Top

connection()

LIST connection()

This function returns a list of information on the current connection. If no connection exists, ~net is thrown. The list is ordered as:

  1. INTEGER - boolean (true if the connection is readable).
  2. INTEGER - boolean (true if the connection is writable).
  3. INTEGER - boolean (true if the connection is dead).
  4. INTEGER - file descriptor.

Most of this information is useful only for debugging, as it can change immediately (all but the file descriptor). This function is primarily useful for determining if the current object has a valid connection.

Top

cwrite()

INTEGER cwrite(BUFFER buffer)

This function writes the buffer data in the argument buffer to the connection on the current object. If there is no connection on the current object a 0 (false) is returned. Otherwise a 1 (true) is returned.

Top

cwritef()

INTEGER cwritef(STRING file_path[, INTEGER block])

This function opens the file specified by file_path and writes its contents directly to the connection. The block size it reads and writes (defaulting to the driver defined variable DEF_BLOCKSIZE in defs.h—usually 512) can be changed by specifying an optional second argument. If the second argument is -1 this function will attempt to read the entire file at once, and write it to the connection. The size of the file (in bytes) is returned. If a problem arises the error ~file is thrown.

Top

open_connection()

INTEGER open_connection(STRING host, INTEGER port)

This function opens an outbound connection to host at port port on the current object. If the host address host is invalid, the error ~address is thrown. If the socket could not be established, ~socket is thrown. For more information, see Networking.

Top

reassign_connection()

INTEGER reassign_connection(OBJNUM new)

This function changes the controlling object for a connection from the current object to the object specified by the argument new. If the new object does not exist, ~objnf is thrown. If the new object already has a connection, the error ~perm is thrown.

Top

unbind_port()

INTEGER unbind_port(INTEGER port)

This function stops listening to the port specified by port. If the object is not listening to the specified port, ~servnf is thrown.

Top

Contents Previous Next Index

Valid XHTML 1.0 Strict