next up previous
Next: socketio Up: simsocket Previous: simsocket


	  internetaddress - handling Internet addressing for Simula
	  Client/Server	applications

	  In order to communicate with a (Server) program on another
	  machine you (the Client) must	know:

	   - the 'Name'	of the other machine (internet address),
	   - the 'Name'	of the program on the other machine (port
	  number), and
	   - the 'Language' it speaks (protocol).
	  Setting up a Server you thus has to define the Port number
	  it uses and the protocol it understands.

	  See the users	manual in

	  Boris	Magnusson, Lund	Institute of Technology.

	     class InternetAddress;
	  Machines on InterNet are really named	 by  32-bit  integers,
	  call	 one   of:   SetHostbyNumber,  SetHostbyInetNumber  OR
	  SetHostbyName	to define the address, and you can then	call:

	  HostName  -  to  get	the   Machine	name   in   the	  form
	  ""  AND  InetNumber  -	to get the real	32-bit
	  Inet address

	  "Clients" usually use	this class to convert from  a  machine
	  Name to its InterNet address as a number.

	  "Servers" use	this class to convert an InterNet address of a
	  connected   Client   to   the	  name	 of  the  Machine  for
	  authorization	etc.

	  Initially an InterNetAddress object will refer to  the  same
	  machine  on which the	program	itself is executing. This will
	  also be the effect after failed calls	to SetHostbyName.

	  Port numbers are  integers defined by	 the  Server  program.
	  The  simplest	way is that both Server	and Client knows about
	  the number.

	  Call 'SetPort' to tell which Port  number  you  will	define
	  services on ("Server"), or want to talk to ("Client").

	  This implementation only support the Protocol	Stream/TCP, in
	  the 'AF_INET'	domain.	Call 'SetStream' to use	that protocol.

	   Super: none
	   Kind: instantiatable
	   Init: Define	Port and Protocol (and also Host for Clients)
	   - SetHostbyName, SetHostbyNumber, or	SetHostbyInetNumber
	   - SetPort and
	   - SetStream
	   Sequence: (
	     SetPort SetStream/SetProtocol
	     GetPort/GetDomain/GetType/GetProtocol) )*

	     boolean procedure SetHostbyName(HostName);
	     text HostName; ! 'name' of	machine	to talk	to;
	  Give the address of the other	machine	by its 'name'  in  the
	  form	 <machine>.<site>.   etc,   example:
	  Returns true if the machine was identified and the name thus
	  was	translated   to	 a  internet  number.	Returns	 false
	  otherwise and	the effect is that the machine denoted by this
	  InterNetAddress  object  is  the  machine  on	 which	it  is
	  executing (which is also true	initially).

	     procedure SetHostbyNumber(n); integer n;
	  Set internet directly	as a 32-bit integer.  There  are  also
	  three	sepcial	cases:

	  INADDR_ANY -	used  by  Servers  to  specify	acceptance  of
	  clinets on any machine.

	  INADDR_LOOPBACK - Debugging facility,	send back to the  same

	  INADDR_BROADCAST - Send to many machines,  note  this	 value
	  has to be masked, not	to transmit to the whole world.

	     procedure SetHostbyInetNumber(i1,i2,i3,i4); integer
	  Set hostnumber by integers grouped  in  four	8-bit  groups,
	  such as

	     procedure SetDGram;
	  Define this connection to use	DataGram/UDP protocol.

	     procedure SetStream;
	  Define this connection to use	Stream/TCP protocol.

	     procedure SetProtocol(Master);
	     ref(InterNetAddress) Master;
	  Define this connection to use	the same  Protocol  as	Master

	     procedure SetPort(Port);
	     integer Port;
	  Define this connection to use	the port-number	'Port'.

	     integer procedure InterNetNumber;
	  Return the Internet number of	the 'other'  machine,  as  set
	  directly  or	looked	up  through the	used hostname. Returns
	  Zero if not initiated, or the	machine	not identified.

	     text procedure HostName;
	  Return the name  of  the  other  machine  in	textual	 form.
	  Retruns  Notext if none of the Set-routines has been called,
	  or the machine could not be identified.

	     integer procedure GetPort;
	  Return  the  connection   port-number	  defined   for	  this

	     integer procedure GetDomain;
	  Return the  Domain  Family  of  the  connection.   Currently
	  allways returns 'AF_INET'

	     integer procedure GetType;
	  Return the 'Type' of the connection, determined by  Protocol
	  chosen.  Currently allways returns 'SOCK_STREAM'

	     integer procedure GetProtocol;
	  Return the Protocol chosen for the connection.

	  Currently allways returns 'IPPROTO_TCP'