eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'IPSocketAddress':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: IPSocketAddress


Inheritance:

   Object
   |
   +--Collection
      |
      +--SequenceableCollection
         |
         +--ArrayedCollection
            |
            +--UninterpretedBytes
               |
               +--SocketAddress
                  |
                  +--IPSocketAddress
                     |
                     +--IPv6SocketAddress

Package:
stx:libbasic2
Category:
OS-Sockets
Version:
rev: 1.54 date: 2018/03/12 14:53:19
user: mawalch
file: IPSocketAddress.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger

Description:


Instances of IPSocketAddress represent tcp/ip-domain socket addresses.
These consist of an ip address (4 bytes) and a port number.

Notice that for performance, name and address translations are cached here
for some time, in order to speed up heavy lookup such as when operating a webserver or similar
application which does many address-to-hostname translations.

For systems, when the name translation is fast (unix), you may want to disable it,
as it prevents new addresses to be detected for some time (for example, if the own address
changes due to a new dhcp address being acquired).
You can also change the cacheing-interval time 
(see caching protocol, flush*Cache, cachingIntervalTime, *CacheSize).


Class protocol:

addressing
o  anyAddress
return the anonymous addresses bytes

o  anyPort
return the anon port number

o  broadcastAddress
return the broadcast address

o  firstUnreservedPort
return the first unreserved port number

o  local
return IN_ADDR_ANY, the address matching any local address

o  maxPort
return the maximum port number

o  thisHost
return the bytes of IN_ADDR_ANY, the address matching any local address

** This is an obsolete interface - do not use it (it may vanish in future versions) **

caching
o  addressCacheAt: aHostName

o  addressCacheAt: aName put: anAddressList

o  addressCacheSize

o  addressCacheSize: aNumber

o  cacheInvalidationTimeInterval

o  cacheInvalidationTimeInterval: seconds

o  flushAddressCache
self flushAddressCache

o  flushNameCache
self flushNameCache

o  nameCacheAt: aHostAddress

o  nameCacheAt: aHostAddress put: aName

o  nameCacheSize

o  nameCacheSize: aNumber

conversion
o  hostAddressFromString: aString
convert an address given in a dot notation like 123.456.78.9
usage example(s):
        IPSocketAddress hostAddressFromString:'1.2.3.4'
        IPSocketAddress hostAddressFromString:'255.255.255.255'

instance creation
o  addressString: aString
convert an address given in a dot notation like 123.456.78.9.
handle IPv6SocketAddresses too.
usage example(s):
     IPSocketAddress addressString:'1.2.3.4'
     IPSocketAddress addressString:'2001:4dd0:ffa3::1'
     IPSocketAddress addressString:'[2001:4dd0:ffa3::1]'

o  allForHostName: name serviceName: portNrOrName type: socketTypeSymbol
get a collection of new instance given a hostname, port or service and type.
Multi-homed hosts return more than one entry
Redefined to cache the result of the name-lookup.

Take care, this resolves to IPv4-addresses only!
Use SocketAddress to resolve to both IPv4 and IPv6-addresses.
usage example(s):
     IPSocketAddress allForHostName:nil serviceName:10 type:#stream
     SocketAddress allForHostName:'localhost' serviceName:10 type:#stream
     IPSocketAddress allForHostName:'localhost' serviceName:'echo' type:#datagram
     IPSocketAddress allForHostName:'www.google.com' serviceName:80 type:nil

     IPSocketAddress allForHostName:'localhost' serviceName:'echo' type:#datagram
     IPv6SocketAddress allForHostName:'localhost' serviceName:'echo' type:#datagram

o  localHost
get a new instance representing the local-host address as seen internally
usage example(s):
     self localHost
     self localHost hostName

o  localHostAddress
NO NO NEVER!
Do not use this, because:
1. It does not work on hosts that get their IP address via dhcp (at least on unix/linux)
2. Usually OperatingSystem>>#getHostName does not return a fully qualified domain name
3. This does not work well on multi-homed hosts

** This is an obsolete interface - do not use it (it may vanish in future versions) **

queries
o  domain

o  hostAddressLen
answer the number of bytes of the host address

o  obsoleteDomainSymbol

o  vwDomainSymbol


Instance protocol:

accessing
o  hostAddress

o  hostAddress: aByteArray

o  port

o  port: aPortNr

comparing
o  sameHostAddress: aSocketAddress
answer true, if myself and aSocketAddress have the same host address
(but possibly different ports).

converting
o  asIPv4SocketAddress

o  asIPv6SocketAddress
convert a IPv4 address to a mapped IPv6SocketAddress
usage example(s):
        (self localHost port:80) asIPv6SocketAddress
        (self localHost port:80) asIPv6SocketAddress asIPv4SocketAddress

obsolete
o  address

printing & storing
o  printAddressOn: aStream
String streamContents:[:s | (IPSocketAddress hostName:'localhost') printAddressOn:s]
(IPSocketAddress hostName:'localhost') printString
(IPSocketAddress hostName:'localhost') hostAddress printString
(IPSocketAddress hostName:'exeptn') printString
(IPSocketAddress hostName:'exeptn') printString

private
o  adrBytesStart

o  numAdrBytes

queries
o  hostName

o  netmaskSize
If this is an address mask: answer the number of mask bits in the address mask
usage example(s):
      (IPSocketAddress addressString:'255.255.0.0') netmaskSize
      (IPSocketAddress addressString:'255.255.128.0') netmaskSize
      (IPv6SocketAddress addressString:'FFFF:FFFF:FFFF:FFFF::') netmaskSize
      (IPv6SocketAddress addressString:'FFFF:FFFF:FFFF:FFF0::') netmaskSize
      (IPv6SocketAddress addressString:'F0FF:FFFF:FFFF:FFF0::') netmaskSize

o  networkAddress
THINK TWICE before using this!
This is deprecated, it doesn't make sense any longer since CIDR, subnetting and netmasks
have been introduced.

Extract and return the network part from the host address.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  networkClass
THINK TWICE before using this!
This is deprecated, it doesn't make sense any longer since subnetting and netmasks
have been introduced.

Extract and return the network class (as a symbol) from the host address.
Returns one of #classA #classB #classC.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  portOrName

testing
o  isBroadcast
answer true, if this is a broadcast address
usage example(s):
        (self hostAddress:self broadcastAddress) isBroadcast

o  isIPSocketAddress

o  isIPv4SocketAddress

o  isLocal
answer true, if this address addresses a peer on the same host
usage example(s):
        self localHost isLocal

o  isMulticast
answer true, if this address is a multicast address 224.0.0.0/4 or Class D

o  isMyAddress
answer true, if the address refers to my own host
usage example(s):
        (IPSocketAddress hostAddress:#[172 23 1 88] port:80) isMyAddress.
        (IPSocketAddress hostAddress:#[192 168 23 29] port:80) isMyAddress.
        (IPv6SocketAddress addressString:'2003:6A:682B:4500:A288:B4FF:FEC6:1514') isMyAddress.
        (IPv6SocketAddress addressString:'2001:6A:682B:4500:A288:B4FF:FEC6:1514') isMyAddress.



ST/X 7.1.0.0; WebServer 1.663 at exept.de:8081; Sun, 22 Jul 2018 12:44:42 GMT