make-passive-socketPortable Socketsremote-hostname-and-portopen-connectionGoTo Top

open-connection   host port => socket-stream[Generic Function]

Purpose
Open a socket-stream connection to server host.

Method signatures

open-connection  (host integer) port => socket-stream
open-connection  (host string) port => socket-stream

Package   :portable-sockets

Module   :portable-sockets

Arguments and values

host     A 32-bit internet address or a string specifying the remote host
port     An integer or a string specifying the service port
socket-stream     A socket stream

Returns
A socket stream.

Description
A host string can be either a host name or a “dotted” IP address, such as "127.0.0.1".

String values available for specifying port are found in the operating system's services file and labeled as being tcp services. On Unix systems, the services file is /etc/services. On Windows, it is the file services in the Windows directory.

See also
    shutdown-socket-stream
    with-open-connection

Example
Open a socket connection to the GBBopen Project web server:

  > (open-connection "GBBopen.org" 80)
  #<socket stream connected from localhost/51756 to gbbopen.org/80>
  >

Note
Connections should always be closed using close (from both sides) when they are no longer needed to free up operating-system resources.


The GBBopen Project


make-passive-socketPortable Socketsremote-hostname-and-portopen-connectionGoTo Top