Next: socketio
Up: simsocket
Previous: simsocket
InternetAddress
NAME
internetaddress - handling Internet addressing for Simula
Client/Server applications
DESCRIPTION
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.
EXAMPLES
See the users manual in simioprocess.ps
AUTHOR
Boris Magnusson, Lund Institute of Technology.
DETAILED INTERFACE
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
"biur.dna.lth.se" 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: (
SetHostbyName/SetHostbyNumber/SetHostbyInetNumber
SetPort SetStream/SetProtocol
(HostName/InterNetNumber/
GetPort/GetDomain/GetType/GetProtocol) )*
INITIALIZATION OPERATIONS
SetHostbyName
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: Biur.dna.lth.se.
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).
SetHostbyNumber
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
socket.
INADDR_BROADCAST - Send to many machines, note this value
has to be masked, not to transmit to the whole world.
SetHostbyInetNumber
procedure SetHostbyInetNumber(i1,i2,i3,i4); integer
i1,i2,i3,i4;
Set hostnumber by integers grouped in four 8-bit groups,
such as 130.21.16.110.
SetDGram
procedure SetDGram;
Define this connection to use DataGram/UDP protocol.
SetStream
procedure SetStream;
Define this connection to use Stream/TCP protocol.
SetProtocol
procedure SetProtocol(Master);
ref(InterNetAddress) Master;
Define this connection to use the same Protocol as Master
does.
SetPort
procedure SetPort(Port);
integer Port;
Define this connection to use the port-number 'Port'.
ENQUERIES OPERATIONS
InterNetNumber
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.
HostName
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.
GetPort
integer procedure GetPort;
Return the connection port-number defined for this
InternetAddress.
GetDomain
integer procedure GetDomain;
Return the Domain Family of the connection. Currently
allways returns 'AF_INET'
GetType
integer procedure GetType;
Return the 'Type' of the connection, determined by Protocol
chosen. Currently allways returns 'SOCK_STREAM'
GetProtocol
integer procedure GetProtocol;
Return the Protocol chosen for the connection.
Currently allways returns 'IPPROTO_TCP'