----------------------------------------------------------------------------- -- -- Onions Network Streams Library -- -- O N I O N S . S O C K E T S -- -- S p e c -- -- Copyright (C) 1997-1998 Regents of the University of California -- -- Onions is free software; you can redistribute it and/or modify it under -- the terms of the GNU General Public License as published by the Free -- Software Foundation, with or without the single exception listed below; -- either version 2, or (at your option) any later version. Onions is -- distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; -- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -- PARTICULAR PURPOSE. See the GNU General Public License for more details. -- You should have received a copy of the GNU General Public License -- distributed with Onions; see the file COPYING. If not, write to the -- Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- 02111-1307, USA. -- -- As a special exception, if other files instantiate generics from this -- library, or you link this library with other files to produce an -- executable, this library does not by itself cause the resulting -- executable to be covered by the GNU General Public License. This -- exception does not however invalidate any other reasons why the -- executable file might be covered by the GNU General Public License. -- -- Portions of this unit have been derived from version 1.02 of the Garlic -- library of GLADE, the Ada95 Distributed Systems Annex for GNAT. GLADE -- is maintained by ACT Europe (see ). -- -- GLADE is Copyright (C) 1996,1997 Free Software Foundation, Inc. -- All source code that is shared by both GLADE version 1.02 and -- this unit remains under the FSF copyright. -- -- Rewritten for Onions in 1997 by Roy T. Fielding and Kari Nies ----------------------------------------------------------------------------- -- -- The Sockets package provides utility routines for connecting -- via sockets, accepting connections via sockets, and setting -- socket options. -- with Interfaces.C; with Onions.Thin; with Onions.Naming; pragma Elaborate_All (Onions.Naming); package Onions.Sockets is -- Convert a port number to a network port number. -- function Port_To_Network (Port : C.unsigned_short) return C.unsigned_short; pragma Inline (Port_To_Network); -- Symmetric operation. -- function Network_To_Port (Net_Port : C.unsigned_short) return C.unsigned_short renames Port_To_Network; pragma Inline (Network_To_Port); In_Address_Any : constant Naming.Address := Naming.Any_Address; type Host_Location is record Addr : Naming.Address := In_Address_Any; Port : C.unsigned_short := 0; end record; -- Establish a socket to a remote location and return the file descriptor. -- Raises Connection_Error if the attempt fails. -- function Establish_Connection (Location : Host_Location) return Thin.Descriptor; -- Image provides a readable form of Host_Location -- function Image (Location : Host_Location) return String; ------------------ -- Exceptions -- ------------------ -- Connection_Error indicates an attempt to use the connect system -- call failed. Raised by Establish_Connection -- Connection_Error : exception; end Onions.Sockets;