An application programming interface for translation of transport-layer
sessions is presented. The system includes kernel-mode support for
application-controlled network address translation and user-mode
implementation of the redirect API routines. In this way, an application
process may request that a network gateway modify the source and/or
destination of a given network session in a manner transparent to the
original source host and/or the replacement destination host. The ability
to perform arbitrary redirection on network sessions under application
control allows the establishment of fast path sessions, server load
balancing, etc. With the generalized NAT (gNAT) of the instant invention
and its associated API, both the source and the destination addresses of
message packets may be changed. The address changes are mapped in the
gNAT, and may result in apparent sessions between different clients and
servers. Depending on the protocol in use (e.g. TCP or UDP), the address
translation may be made dynamically by the gNAT, under the command of the
application, and take place at the kernel level. This significantly
improves the data flow of the system by short-circuiting previously
required data transfer between the kernel and user modes.