SocketAddress.st
author sr
Wed, 17 Jun 2009 18:26:13 +0200
changeset 2171 89e49776d439
parent 2162 cec515dece05
child 2338 7895834d82b4
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
	      All Rights Reserved
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    12
"{ Package: 'stx:libbasic2' }"
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    13
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
    14
UninterpretedBytes variableByteSubclass:#SocketAddress
488
b0c17a5ff8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    15
	instanceVariableNames:''
1229
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    16
	classVariableNames:'DomainToClassMapping'
488
b0c17a5ff8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
    17
	poolDictionaries:''
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
    18
	category:'OS-Sockets'
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
    21
!SocketAddress primitiveDefinitions!
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
    22
%{
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
    23
#include "stxOSDefs.h"
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
    24
%}
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
    25
! !
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
    26
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
!SocketAddress class methodsFor:'documentation'!
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
copyright
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
"
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 COPYRIGHT (c) 1995 by Claus Gittinger
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
	      All Rights Reserved
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 This software is furnished under a license and may be used
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 only in accordance with the terms of that license and with the
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 inclusion of the above copyright notice.   This software may not
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 be provided or otherwise made available to, or used by, any
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
 other person.  No title to or ownership of the software is
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
 hereby transferred.
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
!
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
documentation
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
"
111
92392ae9a0f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 100
diff changeset
    45
    Abstract superclass for subclasses implementing various IPC addressing schemes.
92392ae9a0f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 100
diff changeset
    46
    See concrete examples IPSocketAddress and UDSocketAddress.
92392ae9a0f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 100
diff changeset
    47
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    ST-80 compatibility class.
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    This may be required when existing code has to be ported to ST/X;
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    however, it may not be complete and more protocol may be added in the future.
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    The code here was created when public domain code (Manchester) had to
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
    be ported to ST/X and missing classes/methods were encountered, and code added
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    by reasoning 'what the original class could probably do there'.
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    This is an additional goody class; therefore:
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTOR ``AS IS'' AND
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    ARE DISCLAIMED.  IN NO EVENT SHALL THE CONTRIBUTOR BE LIABLE
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    SUCH DAMAGE.
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
"
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
! !
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
    71
!SocketAddress class methodsFor:'instance creation'!
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
    72
1910
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    73
allForHostName:name
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    74
    "get a collection of new instances given a hostname"
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    75
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    76
    ^ self allForHostName:name serviceName:nil type:nil
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    77
!
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    78
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    79
allForHostName:name port:portNr
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    80
    "get a collection of new instances given a hostname and port"
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    81
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    82
    ^ self allForHostName:name serviceName:portNr type:nil
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    83
!
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    84
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    85
allForHostName:name serviceName:portNrOrName type:socketTypeSymbol
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    86
    "get a collection of new instances given a hostname, port or service and type.
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    87
     Multi-homed hosts return more than one entry"
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    88
1914
8a6e5feaeaef simplified numeric port handling in #allForHostname:...
Stefan Vogel <sv@exept.de>
parents: 1910
diff changeset
    89
    |addressInfo|
1910
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    90
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    91
    addressInfo := self 
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    92
                    getAddressInfo:name 
1914
8a6e5feaeaef simplified numeric port handling in #allForHostname:...
Stefan Vogel <sv@exept.de>
parents: 1910
diff changeset
    93
                    serviceName:portNrOrName 
1910
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    94
                    domain:(self domainSymbol) 
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    95
                    type:socketTypeSymbol
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    96
                    protocol:nil 
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    97
                    flags:0.
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    98
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
    99
    ^ addressInfo 
1914
8a6e5feaeaef simplified numeric port handling in #allForHostname:...
Stefan Vogel <sv@exept.de>
parents: 1910
diff changeset
   100
        collect:[:eachAddressInfo| eachAddressInfo socketAddress].
1910
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   101
        
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   102
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   103
    "
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   104
     SocketAddress allForHostName:'localhost' serviceName:10 type:#stream
1914
8a6e5feaeaef simplified numeric port handling in #allForHostname:...
Stefan Vogel <sv@exept.de>
parents: 1910
diff changeset
   105
     SocketAddress allForHostName:'localhost' serviceName:'10' type:#stream
1910
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   106
     IPSocketAddress allForHostName:'localhost' serviceName:'echo' type:#datagram 
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   107
     IPSocketAddress allForHostName:'localhost' serviceName:'echo' type:nil
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   108
     IPSocketAddress allForHostName:'google.com' serviceName:'http' type:nil
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   109
    "
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   110
!
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   111
1281
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
   112
anyHost
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
   113
    "get a new instance representing the ANY-host address"
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
   114
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
   115
    ^ self hostAddress:(self anyAddress) port:0
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
   116
!
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
   117
1580
fa4a40f26603 new: fromBytes:
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   118
fromBytes:bytes
fa4a40f26603 new: fromBytes:
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   119
    "create a socket address from bytes (ByteArray), returned by the
fa4a40f26603 new: fromBytes:
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   120
     primitive syscalls"
fa4a40f26603 new: fromBytes:
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   121
fa4a40f26603 new: fromBytes:
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   122
     |domainSymbol|
fa4a40f26603 new: fromBytes:
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   123
fa4a40f26603 new: fromBytes:
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   124
     domainSymbol := OperatingSystem domainSymbolOf:(bytes unsignedShortAt:1).
fa4a40f26603 new: fromBytes:
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   125
     ^ (SocketAddress newDomain:domainSymbol) fromBytes:bytes.
fa4a40f26603 new: fromBytes:
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   126
!
fa4a40f26603 new: fromBytes:
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   127
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   128
hostAddress:addr
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   129
    "get a new instance given addr-bytes"
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   130
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   131
    ^ self hostAddress:addr port:0
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   132
!
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   133
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   134
hostAddress:addr port:portNr
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   135
    "get a new instance given addr-bytes and a portNr"
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   136
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   137
    ^ self new hostAddress:addr; port:portNr
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   138
!
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   139
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   140
hostName:name
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   141
    "get a new instance given a hostname"
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   142
2171
89e49776d439 *** empty log message ***
sr
parents: 2162
diff changeset
   143
    ^ self hostName:name serviceName:nil type:nil.
89e49776d439 *** empty log message ***
sr
parents: 2162
diff changeset
   144
89e49776d439 *** empty log message ***
sr
parents: 2162
diff changeset
   145
    "Modified: / 17-06-2009 / 15:25:42 / sr"
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   146
!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   147
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   148
hostName:name port:portNr
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   149
    "get a new instance given a hostname and port"
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   150
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   151
    ^ self hostName:name serviceName:portNr type:nil
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   152
!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   153
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   154
hostName:name serviceName:portNrOrName type:socketTypeSymbol
1910
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   155
    "get a new instance given a hostname, port or service and type.
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   156
     Do not use this, since it does not work for multi-homed hosts"
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   157
1910
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   158
    |addressList sa|
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   159
1910
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   160
    addressList := self allForHostName:name serviceName:portNrOrName type:socketTypeSymbol.
2162
cec515dece05 return the last socketAddress from a multi-list, instead of the first
Michael Beyl <mb@exept.de>
parents: 1934
diff changeset
   161
    sa := addressList last.
1910
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   162
    addressList size > 1 ifTrue:[
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   163
        (addressList contains:[:entry| entry  ~= sa]) ifTrue:[
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   164
            ('SocketAddress [warning]: multiple hostAddresses for host: ', name) infoPrintCR.
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   165
            addressList do:[:entry| '  ' infoPrint. entry infoPrintCR].
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   166
            (addressList detect:[:entry| entry ~= sa] ifNone:nil) infoPrintCR.
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   167
        ].
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   168
    ].
1910
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   169
    ^ sa.
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   170
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   171
    "
2162
cec515dece05 return the last socketAddress from a multi-list, instead of the first
Michael Beyl <mb@exept.de>
parents: 1934
diff changeset
   172
     SocketAddress hostName:'localhost' serviceName:10 type:#stream  
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   173
     IPSocketAddress hostName:'localhost' serviceName:'echo' type:#datagram 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   174
     IPSocketAddress hostName:'localhost' serviceName:'echo' type:nil
1910
92504f2834ce Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents: 1895
diff changeset
   175
     IPSocketAddress hostName:'www.google.com' serviceName:'http' type:nil
2162
cec515dece05 return the last socketAddress from a multi-list, instead of the first
Michael Beyl <mb@exept.de>
parents: 1934
diff changeset
   176
     SocketAddress allForHostName:'localhost' serviceName:10 type:#stream.
cec515dece05 return the last socketAddress from a multi-list, instead of the first
Michael Beyl <mb@exept.de>
parents: 1934
diff changeset
   177
     SocketAddress allForHostName:'www.google.com' serviceName:10 type:#stream.
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   178
    "
2171
89e49776d439 *** empty log message ***
sr
parents: 2162
diff changeset
   179
89e49776d439 *** empty log message ***
sr
parents: 2162
diff changeset
   180
    "Modified: / 17-06-2009 / 15:25:35 / sr"
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   181
!
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   182
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   183
new
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   184
    |numBytes|
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   185
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   186
    self == SocketAddress ifTrue:[
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   187
        self error:'SocketAddress is abstract'.
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   188
    ].
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   189
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   190
    numBytes := self socketAddressSize.
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   191
    numBytes isNil ifTrue:[
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   192
        self error:'unsupported domain'.
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   193
        ^ nil
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   194
    ].
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   195
    ^ (self new:numBytes) domainCode:(self domainCode)
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   196
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   197
    "
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   198
     IPSocketAddress new            
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   199
     IPv6SocketAddress new          
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   200
     UDSocketAddress new            
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   201
     AppletalkSocketAddress new
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   202
   "
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   203
!
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   204
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   205
newDomain:domain
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   206
   "answer an new socket address for a given domain"
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   207
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   208
   ^ (self knownClassFromCode:domain) new
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   209
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   210
   "
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   211
    self newDomain:#afUnix    
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   212
    self newDomain:#afInet    
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   213
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   214
    self newDomain:#'AF_UNIX' 
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   215
    self newDomain:#'AF_INET' 
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   216
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   217
    self newDomain:#unix
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   218
    self newDomain:#inet
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   219
   "
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   220
! !
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   221
1281
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
   222
!SocketAddress class methodsFor:'addressing'!
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
   223
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
   224
anyAddress
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
   225
    self subclassResponsibility
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
   226
! !
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1279
diff changeset
   227
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
!SocketAddress class methodsFor:'queries'!
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   230
domainCode
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   231
    "answer the numerical domain code used in socket addresses"
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   232
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   233
    ^ OperatingSystem domainCodeOf:(self domainSymbol)
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   234
!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   235
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
domainCodeFromName:aNameSymbol
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   237
    "this is a compatibility method;
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   238
     VW returns the internal unix codes here - however, in ST/X,
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   239
     symbols are returned, which are translated later"
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   240
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   241
    aNameSymbol isInteger ifTrue:[ ^ aNameSymbol ].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   242
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   243
    "here, all possible variants are translated to AF_* symbols,
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   244
     which are handled by the primitives"
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   245
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   246
    aNameSymbol == #afUnix      ifTrue:[^ #'AF_UNIX'].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   247
    aNameSymbol == #AF_UNIX     ifTrue:[^ #'AF_UNIX'].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   248
    aNameSymbol == #unix        ifTrue:[^ #'AF_UNIX'].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   249
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   250
    aNameSymbol == #afInet      ifTrue:[^ #'AF_INET'].    
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   251
    aNameSymbol == #'AF_INET'   ifTrue:[^ #'AF_INET'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   252
    aNameSymbol == #inet        ifTrue:[^ #'AF_INET'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   253
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   254
    aNameSymbol == #afIpV6      ifTrue:[^ #'AF_INET6'].    
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   255
    aNameSymbol == #'AF_INET6'  ifTrue:[^ #'AF_INET6'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   256
    aNameSymbol == #inet6       ifTrue:[^ #'AF_INET6'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   257
    aNameSymbol == #afInet6     ifTrue:[^ #'AF_INET6'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   258
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   259
    aNameSymbol == #afAppletalk    ifTrue:[^ #'AF_APPLETALK'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   260
    aNameSymbol == #'AF_APPLETALK' ifTrue:[^ #'AF_APPLETALK'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   261
    aNameSymbol == #appletalk      ifTrue:[^ #'AF_APPLETALK'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   262
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   263
    aNameSymbol == #afDecnet    ifTrue:[^ #'AF_DECnet'].    
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   264
    aNameSymbol == #'AF_DECnet' ifTrue:[^ #'AF_DECnet'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   265
    aNameSymbol == #'AF_DECNET' ifTrue:[^ #'AF_DECnet'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   266
    aNameSymbol == #decnet      ifTrue:[^ #'AF_DECnet'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   267
    aNameSymbol == #decNet      ifTrue:[^ #'AF_DECnet'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   268
    aNameSymbol == #DECnet      ifTrue:[^ #'AF_DECnet'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   269
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   270
    aNameSymbol == #afSna       ifTrue:[^ #'AF_SNA'].    
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   271
    aNameSymbol == #'AF_SNA'    ifTrue:[^ #'AF_SNA'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   272
    aNameSymbol == #sna         ifTrue:[^ #'AF_SNA'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   273
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   274
    aNameSymbol == #afNs        ifTrue:[^ #'AF_NS'].    
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   275
    aNameSymbol == #'AF_NS'     ifTrue:[^ #'AF_NS'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   276
    aNameSymbol == #ns          ifTrue:[^ #'AF_NS'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   277
    aNameSymbol == #xns         ifTrue:[^ #'AF_NS'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   278
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   279
    aNameSymbol == #afCcitt     ifTrue:[^ #'AF_CCITT'].    
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   280
    aNameSymbol == #'AF_CCITT'  ifTrue:[^ #'AF_CCITT'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   281
    aNameSymbol == #ccitt       ifTrue:[^ #'AF_CCITT'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   282
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   283
    aNameSymbol == #afImplink    ifTrue:[^ #'AF_IMPLINK'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   284
    aNameSymbol == #'AF_IMPLINK' ifTrue:[^ #'AF_IMPLINK'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   285
    aNameSymbol == #implink      ifTrue:[^ #'AF_IMPLINK'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   286
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   287
    aNameSymbol == #afPup       ifTrue:[^ #'AF_PUP'].    
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   288
    aNameSymbol == #'AF_PUP'    ifTrue:[^ #'AF_PUP'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   289
    aNameSymbol == #pup         ifTrue:[^ #'AF_PUP'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   290
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   291
    aNameSymbol == #afChaos    ifTrue:[^ #'AF_CHAOS'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   292
    aNameSymbol == #'AF_CHAOS' ifTrue:[^ #'AF_CHAOS'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   293
    aNameSymbol == #chaos      ifTrue:[^ #'AF_CHAOS'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   294
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   295
    aNameSymbol == #afEcma      ifTrue:[^ #'AF_ECMA'].    
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   296
    aNameSymbol == #'AF_ECMA'   ifTrue:[^ #'AF_ECMA'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   297
    aNameSymbol == #ecma        ifTrue:[^ #'AF_ECMA'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   298
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   299
    aNameSymbol == #afDatakit    ifTrue:[^ #'AF_DATAKIT'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   300
    aNameSymbol == #'AF_DATAKIT' ifTrue:[^ #'AF_DATAKIT'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   301
    aNameSymbol == #datakit      ifTrue:[^ #'AF_DATAKIT'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   302
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   303
    aNameSymbol == #afDli     ifTrue:[^ #'AF_DLI'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   304
    aNameSymbol == #'AF_DLI'  ifTrue:[^ #'AF_DLI'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   305
    aNameSymbol == #dli       ifTrue:[^ #'AF_DLI'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   306
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   307
    aNameSymbol == #afLat     ifTrue:[^ #'AF_LAT'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   308
    aNameSymbol == #'AF_LAT'  ifTrue:[^ #'AF_LAT'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   309
    aNameSymbol == #lat       ifTrue:[^ #'AF_LAT'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   310
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   311
    aNameSymbol == #afHylink    ifTrue:[^ #'AF_HYLINK'].    
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   312
    aNameSymbol == #'AF_HYLINK' ifTrue:[^ #'AF_HYLINK'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   313
    aNameSymbol == #hylink      ifTrue:[^ #'AF_HYLINK'].    
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   314
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   315
    aNameSymbol == #afUnspec    ifTrue:[^ #'AF_UNSPEC'].    
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   316
    aNameSymbol == #'AF_UNSPEC' ifTrue:[^ #'AF_UNSPEC'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   317
    aNameSymbol == #unspec      ifTrue:[^ #'AF_UNSPEC'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   318
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   319
    aNameSymbol == #afRaw    ifTrue:[^ #'AF_RAW'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   320
    aNameSymbol == #'AF_RAW' ifTrue:[^ #'AF_RAW'].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   321
    aNameSymbol == #raw      ifTrue:[^ #'AF_RAW'].    
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   322
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
    "/
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
    "/ could someone tell me which symbols are used in ST-80's SocketAddress class ?
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
    "/
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
    self error:'no more mimicri implemented yet ...'
602
b7afbf8a1589 Support #afInet.
Stefan Vogel <sv@exept.de>
parents: 488
diff changeset
   327
b7afbf8a1589 Support #afInet.
Stefan Vogel <sv@exept.de>
parents: 488
diff changeset
   328
    "Modified: / 9.1.1998 / 10:03:56 / stefan"
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   329
!
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   330
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   331
domainNameFromCode:code
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   332
    "this is a compatibility method;
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   333
     VW expects the internal unix codes here - however, in ST/X,
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   334
     symbols are expected - keeping the numeric values secret (in Socket)"
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   335
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   336
    code == #unix           ifTrue:[^ #afUnix].
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   337
    code == #'AF_UNIX'      ifTrue:[^ #afUnix].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   338
    code == #'afUnix'       ifTrue:[^ #afUnix].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   339
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   340
    code == #inet           ifTrue:[^ #afInet].
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   341
    code == #'AF_INET'      ifTrue:[^ #afInet].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   342
    code == #'afInet'       ifTrue:[^ #afInet].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   343
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   344
    code == #inet6          ifTrue:[^ #afIpV6].
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   345
    code == #'AF_INET6'     ifTrue:[^ #afIpV6].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   346
    code == #'afIpV6'       ifTrue:[^ #afIpV6].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   347
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   348
    code == #appletalk      ifTrue:[^ #afAppletalk].
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   349
    code == #'AF_APPLETALK' ifTrue:[^ #afAppletalk].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   350
    code == #'afAppletalk'  ifTrue:[^ #afAppletalk].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   351
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   352
    code == #decnet         ifTrue:[^ #afDecnet].
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   353
    code == #DECnet         ifTrue:[^ #afDecnet].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   354
    code == #decNet         ifTrue:[^ #afDecnet].
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   355
    code == #'AF_DECNET'    ifTrue:[^ #afDecnet].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   356
    code == #'AF_DECnet'    ifTrue:[^ #afDecnet].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   357
    code == #'afDecnet'     ifTrue:[^ #afDecnet].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   358
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   359
    code == #sna            ifTrue:[^ #afSna].
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   360
    code == #'AF_SNA'       ifTrue:[^ #afSna].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   361
    code == #'afSna'        ifTrue:[^ #afSna].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   362
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   363
    code == #xns            ifTrue:[^ #afNs].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   364
    code == #ns             ifTrue:[^ #afNs].
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   365
    code == #'AF_NS'        ifTrue:[^ #afNs].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   366
    code == #'afNs'         ifTrue:[^ #afNs].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   367
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   368
    code == #ccitt          ifTrue:[^ #afCcitt].
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   369
    code == #'AF_CCITT'     ifTrue:[^ #afCcitt].
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   370
    code == #'afCcitt'      ifTrue:[^ #afCcitt].
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   371
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   372
    code == #implink      ifTrue:[^ #afImplink].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   373
    code == #'AF_IMPLINK' ifTrue:[^ #afImplink].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   374
    code == #afImplink    ifTrue:[^ #afImplink].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   375
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   376
    code == #pup         ifTrue:[^ #afPup].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   377
    code == #'AF_PUP'    ifTrue:[^ #afPup].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   378
    code == #afPup       ifTrue:[^ #afPup].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   379
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   380
    code == #chaos      ifTrue:[^ #afChaos].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   381
    code == #'AF_CHAOS' ifTrue:[^ #afChaos].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   382
    code == #afChaos    ifTrue:[^ #afChaos].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   383
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   384
    code == #ecma        ifTrue:[^ #afEcma].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   385
    code == #'AF_ECMA'   ifTrue:[^ #afEcma].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   386
    code == #afEcma      ifTrue:[^ #afEcma].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   387
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   388
    code == #datakit      ifTrue:[^ #afDatakit].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   389
    code == #'AF_DATAKIT' ifTrue:[^ #afDatakit].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   390
    code == #afDatakit    ifTrue:[^ #afDatakit].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   391
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   392
    code == #dli       ifTrue:[^ #afDli].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   393
    code == #'AF_DLI'  ifTrue:[^ #afDli].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   394
    code == #afDli     ifTrue:[^ #afDli].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   395
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   396
    code == #lat       ifTrue:[^ #afLat].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   397
    code == #'AF_LAT'  ifTrue:[^ #afLat].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   398
    code == #afLat     ifTrue:[^ #afLat].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   399
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   400
    code == #hylink      ifTrue:[^ #afHylink].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   401
    code == #'AF_HYLINK' ifTrue:[^ #afHylink].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   402
    code == #afHylink    ifTrue:[^ #afHylink].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   403
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   404
    code == #unspec      ifTrue:[^ #afUnspec].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   405
    code == #'AF_UNSPEC' ifTrue:[^ #afUnspec].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   406
    code == #afUnspec    ifTrue:[^ #afUnspec].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   407
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   408
    code == #raw      ifTrue:[^ #afRaw].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   409
    code == #'AF_RAW' ifTrue:[^ #afRaw].    
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   410
    code == #afRaw    ifTrue:[^ #afRaw].    
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   411
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   412
    "/
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   413
    "/ could someone tell me which symbols are used in ST-80's SocketAddress class ?
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   414
    "/
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   415
    self error:'no more mimicri implemented yet ...'
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   416
!
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   417
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   418
domainSymbol
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   419
    "Answer the domain symbol. Subclasses redefine this"
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   420
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   421
    self == SocketAddress ifTrue:[
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   422
        ^ nil
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   423
    ] ifFalse:[
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   424
        self subclassResponsibility
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   425
    ]
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   426
!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   427
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   428
getAddressInfo:hostName serviceName:serviceName domain:domainArg type:typeArg protocol:protoArg flags:flags 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   429
    "answer an Array of socket addresses for serviceName on hostName
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   430
     Domain, type, protocol may be nil or specify a hint for the socket 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   431
     addresses to be returned."
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   432
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   433
    ^ OperatingSystem socketAccessor 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   434
            getAddressInfo:hostName serviceName:serviceName 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   435
            domain:domainArg type:typeArg protocol:protoArg flags:flags 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   436
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   437
    "
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   438
     self getAddressInfo:'localhost' serviceName:nil 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   439
            domain:nil type:nil protocol:nil flags:nil
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   440
     self getAddressInfo:'localhost' serviceName:nil 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   441
            domain:#inet type:#stream protocol:nil flags:nil
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   442
     self getAddressInfo:'localhost' serviceName:nil 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   443
            domain:#inet type:#stream protocol:#tcp flags:nil
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   444
     self getAddressInfo:'blurb.exept.de' serviceName:nil 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   445
            domain:#inet type:nil protocol:nil flags:nil
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   446
     self getAddressInfo:'1.2.3.4' serviceName:'6' 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   447
            domain:#inet type:nil protocol:nil flags:nil
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   448
     self getAddressInfo:'localhost' serviceName:'echo' 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   449
            domain:#inet6 type:nil protocol:nil flags:nil
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   450
    "
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   451
!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   452
1167
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   453
getAddressInfo:hostName serviceName:serviceName type:typeArg protocol:protoArg flags:flags 
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   454
    "answer an Array of socket addresses for serviceName on hostName
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   455
     Domain, type, protocol may be nil or specify a hint for the socket 
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   456
     addresses to be returned."
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   457
1232
49ce4681f1c0 dont wine if we get multiple host addresses for a name
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   458
    ^ self  
49ce4681f1c0 dont wine if we get multiple host addresses for a name
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   459
        getAddressInfo:hostName serviceName:serviceName 
49ce4681f1c0 dont wine if we get multiple host addresses for a name
Claus Gittinger <cg@exept.de>
parents: 1229
diff changeset
   460
        domain:(self domainCode) type:typeArg protocol:protoArg flags:flags 
1167
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   461
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   462
    "
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   463
     IPSocketAddress getAddressInfo:'localhost' serviceName:nil 
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   464
                     type:nil protocol:nil flags:nil
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   465
     IPSocketAddress getAddressInfo:'localhost' serviceName:nil 
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   466
                     type:#stream protocol:nil flags:nil
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   467
     IPSocketAddress getAddressInfo:'localhost' serviceName:nil 
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   468
                     type:#stream protocol:#tcp flags:nil
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   469
     IPSocketAddress getAddressInfo:'blurb.exept.de' serviceName:nil 
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   470
                     type:nil protocol:nil flags:nil
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   471
     IPSocketAddress getAddressInfo:'1.2.3.4' serviceName:'6' 
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   472
                     type:nil protocol:nil flags:nil
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   473
     IPSocketAddress getAddressInfo:'localhost' serviceName:'echo' 
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   474
                     type:nil protocol:nil flags:nil
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   475
    "
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   476
!
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1164
diff changeset
   477
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   478
getNameInfo:socketAddress wantHostName:wantHostName wantServiceName:wantServiceName datagram:useDatagram flags:flags 
1262
d3daddd36a99 no longer callBack into sockets getHostName/getAddress code.
Claus Gittinger <cg@exept.de>
parents: 1259
diff changeset
   479
    "answer an Array containing the hostName and/or serviceName
d3daddd36a99 no longer callBack into sockets getHostName/getAddress code.
Claus Gittinger <cg@exept.de>
parents: 1259
diff changeset
   480
     for a given socketAddress."
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   481
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   482
    ^ OperatingSystem socketAccessor
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   483
            getNameInfo:socketAddress wantHostName:wantHostName 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   484
            wantServiceName:wantServiceName datagram:useDatagram flags:flags 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   485
    
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   486
    "
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   487
     self getNameInfo:
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   488
         (self getAddressInfo:'localhost' serviceName:'echo' 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   489
                domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
1262
d3daddd36a99 no longer callBack into sockets getHostName/getAddress code.
Claus Gittinger <cg@exept.de>
parents: 1259
diff changeset
   490
         wantHostName:true wantServiceName:true datagram:false flags:0     
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   491
    "
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   492
!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   493
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   494
knownClassFromCode:code
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   495
    "this is a compatibility method;
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   496
     VW expects the internal unix codes here - however, in ST/X,
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   497
     symbols are expected - keeping the numeric values secret (in Socket)"
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   498
1229
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   499
    |cls|
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   500
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   501
    DomainToClassMapping isNil ifTrue:[
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   502
        DomainToClassMapping := IdentityDictionary new
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   503
    ].
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   504
    cls := DomainToClassMapping at:code ifAbsent:nil.
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   505
    cls notNil ifTrue:[^ cls].
1259
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   506
1226
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   507
    code notNil ifTrue:[
1259
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   508
        "/ some are always known...
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   509
        DomainToClassMapping at:#unix put:UDSocketAddress.
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   510
        DomainToClassMapping at:#inet put:IPSocketAddress.
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   511
        DomainToClassMapping at:#inet6 put:IPv6SocketAddress.
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   512
        DomainToClassMapping at:#appletalk put:AppletalkSocketAddress.
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   513
        DomainToClassMapping at:#decnet put:DecNetSocketAddress.
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   514
1229
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   515
        self allSubclassesDo:[:aSubClass|
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   516
            (aSubClass domainCode == code
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   517
            or:[aSubClass domainSymbol == code
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   518
            or:[aSubClass obsoleteDomainSymbol == code
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   519
            or:[aSubClass vwDomainSymbol == code]]])
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   520
            ifTrue:[
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   521
                DomainToClassMapping at:code put:aSubClass.
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   522
                ^ aSubClass
1226
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   523
            ].
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   524
        ].
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   525
    ].
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   526
    ^ SocketAddress
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   527
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   528
    "
1273
03afdf3f895e addrCache and nameCache must be separate for
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
   529
     DomainToClassMapping := nil.
03afdf3f895e addrCache and nameCache must be separate for
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
   530
1229
b96b65284981 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   531
     self knownClassFromCode:#'AF_UNIX' 
1226
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   532
     self knownClassFromCode:#'AF_INET'
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   533
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   534
     self knownClassFromCode:1
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   535
     self knownClassFromCode:2
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   536
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   537
     self knownClassFromCode:#unix             obsolete ST/X codes
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   538
     self knownClassFromCode:#inet
1226
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   539
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   540
     self knownClassFromCode:#afUnix           visualWorks codes
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   541
     self knownClassFromCode:#afInet
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   542
    "
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   543
!
816
489e7876ab3e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
   544
1226
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   545
obsoleteDomainSymbol
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   546
    ^ nil
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   547
!
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   548
1259
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   549
peerNameFromPeer:peer
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   550
    ^ peer hostName
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   551
!
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   552
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   553
socketAddressSize
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   554
    "answer the OS specific size of a socket address.
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   555
     Returns nil, if the domain is not supported or invalid."
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   556
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   557
    ^ OperatingSystem socketAddressSizeOfDomain:(self domainSymbol)
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   558
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   559
    "
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   560
     SocketAddress socketAddressSize  
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   561
     UDSocketAddress socketAddressSize  
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   562
     IPSocketAddress socketAddressSize  
1279
13ccd72f5f5d moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 1273
diff changeset
   563
     IPv6SocketAddress socketAddressSize 
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   564
     AppletalkSocketAddress socketAddressSize  
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   565
     DecNetSocketAddress socketAddressSize     
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   566
    "
1226
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   567
!
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   568
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   569
vwDomainSymbol
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1225
diff changeset
   570
    ^ nil
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
! !
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   573
!SocketAddress methodsFor:'accessing'!
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   574
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   575
domainCode
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   576
    ^ self unsignedShortAt:1
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   577
!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   578
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   579
domainCode:anInteger
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   580
    self unsignedShortAt:1 put:anInteger
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   581
!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   582
1223
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   583
hostAddress:addressBytes
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   584
    "generic method, subclasses usually redefine this"
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   585
1223
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   586
    "/ the first 2-bytes (a short) is the domainCode
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   587
    self replaceBytesFrom:1+2 to:addressBytes size+2 with:addressBytes startingAt:1
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   588
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   589
    "
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   590
     IPSocketAddress hostAddress:#[193 141 12 193] port:80
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   591
    "
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   592
!
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   593
1223
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   594
hostAddress:addressBytes port:portNr
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   595
    self hostAddress:addressBytes.
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   596
    self port:portNr
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   597
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   598
    "
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   599
     IPSocketAddress hostAddress:#[193 141 12 193] port:10
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   600
    "
1223
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   601
!
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   602
1934
fee89061a2e0 +hostAddressString
Claus Gittinger <cg@exept.de>
parents: 1914
diff changeset
   603
hostAddressString
fee89061a2e0 +hostAddressString
Claus Gittinger <cg@exept.de>
parents: 1914
diff changeset
   604
    ^ String streamContents:[:s | self printAddressOn:s ].
fee89061a2e0 +hostAddressString
Claus Gittinger <cg@exept.de>
parents: 1914
diff changeset
   605
!
fee89061a2e0 +hostAddressString
Claus Gittinger <cg@exept.de>
parents: 1914
diff changeset
   606
1223
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   607
port
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   608
    self subclassResponsibility
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   609
!
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   610
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   611
port:portNr
24b2821edf3f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   612
    self subclassResponsibility
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   613
! !
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 816
diff changeset
   614
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   615
!SocketAddress methodsFor:'printing & storing'!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   616
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   617
displayString
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   618
    "redefine from Collection"
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   619
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   620
    |s|
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   621
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   622
    s := WriteStream on:''.
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   623
    self printOn:s.
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   624
    ^ s contents.
1333
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   625
!
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   626
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   627
printAddressOn:arg 
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   628
    "raise an error: must be redefined in concrete subclass(es)"
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   629
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   630
    ^ self subclassResponsibility
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   631
!
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   632
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   633
printOn:aStream
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   634
    "append a user printed representation of the receiver to aStream.
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   635
     The format is suitable for a human - not meant to be read back."
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   636
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   637
    self printOn:aStream withPort:true
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   638
!
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   639
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   640
printOn:aStream withPort:withPort
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   641
    "append a user printed representation of the receiver to aStream.
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   642
     The format is suitable for a human - not meant to be read back."
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   643
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   644
    self printAddressOn:aStream.
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   645
    withPort ifTrue:[
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   646
        self printPortOn:aStream.
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   647
    ].
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   648
!
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   649
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   650
printPortOn:aStream 
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   651
    |port|
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   652
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   653
    (port := self port) ~~ 0 ifTrue:[
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   654
        aStream nextPut:$:.
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   655
        port printOn:aStream.
d9ebcc42524c printing refactored
penk
parents: 1281
diff changeset
   656
    ]
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   657
! !
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   658
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   659
!SocketAddress methodsFor:'private'!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   660
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   661
fromBytes:aByteArray
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   662
    "Copy the internal representation of a SocketAddress to myself
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   663
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   664
     This is an internal interface!!"
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   665
1225
8839f52dde96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   666
    self replaceBytesFrom:1 to:(self size) with:aByteArray startingAt:1.
8839f52dde96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   667
8839f52dde96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1223
diff changeset
   668
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   669
! !
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   670
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   671
!SocketAddress methodsFor:'queries'!
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   672
488
b0c17a5ff8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   673
address
b0c17a5ff8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   674
    ^ self subclassResponsibility
b0c17a5ff8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   675
!
b0c17a5ff8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   676
111
92392ae9a0f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 100
diff changeset
   677
hostName
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   678
    ^ (self class getNameInfo:self wantHostName:true 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   679
                  wantServiceName:false datagram:false flags:0) first
111
92392ae9a0f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 100
diff changeset
   680
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   681
    "
1259
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   682
     (IPSocketAddress hostAddress:#[127 0 0 1]) hostName        
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   683
     (IPSocketAddress hostName:'localhost') address        
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   684
     (IPSocketAddress hostName:'www.google.com') address        
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   685
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   686
     (IPSocketAddress hostAddress:#[127 0 0 1] port:7) hostName        
0a557e59ea4a instance creation refactored
Claus Gittinger <cg@exept.de>
parents: 1232
diff changeset
   687
     (IPSocketAddress hostAddress:#[193 141 12 193] port:10) hostName  
1228
b766b9873ba6 refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents: 1226
diff changeset
   688
     (IPSocketAddress hostAddress:#[193 141 12 244]) hostName 
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   689
    "
111
92392ae9a0f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 100
diff changeset
   690
!
92392ae9a0f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 100
diff changeset
   691
1366
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   692
hostNameOrAddressString
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   693
    "answer the host name or the string representation
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   694
     of the address"
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   695
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   696
    ^ [
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   697
        self hostName.
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   698
    ] on:NameLookupError do:[:ex| |stream|
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   699
        stream := '' writeStream.
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   700
        self printAddressOn:stream.
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   701
        stream contents.
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   702
    ].
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   703
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   704
    "
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   705
        (IPSocketAddress hostName:'localhost') hostNameOrAddressString
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   706
        (IPSocketAddress hostAddress:#[192 168 8 33]) hostNameOrAddressString
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   707
    "
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   708
!
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   709
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   710
portOrName
210
d940e6a66526 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   711
    ^ self subclassResponsibility
1164
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   712
!
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   713
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   714
serviceName
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   715
    ^ (self class getNameInfo:self wantHostName:false 
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   716
                  wantServiceName:true datagram:false flags:0) second
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   717
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   718
    "
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   719
     (IPSocketAddress hostAddress:#[127 0 0 1] port:7) serviceName
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   720
     (IPSocketAddress hostAddress:#[193 141 12 193] port:10) serviceName
41a2750af1fa New socket support
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   721
    "
100
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   722
! !
058d9257c30d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   723
1366
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   724
!SocketAddress methodsFor:'testing'!
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   725
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   726
isLocal
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   727
    "answer true, if this address adresses a peer on the same host"
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   728
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   729
    ^ self subclassResponsibility
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   730
! !
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1333
diff changeset
   731
488
b0c17a5ff8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   732
!SocketAddress class methodsFor:'documentation'!
b0c17a5ff8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   733
b0c17a5ff8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   734
version
2171
89e49776d439 *** empty log message ***
sr
parents: 2162
diff changeset
   735
    ^ '$Header: /cvs/stx/stx/libbasic2/SocketAddress.st,v 1.31 2009-06-17 16:26:13 sr Exp $'
488
b0c17a5ff8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 210
diff changeset
   736
! !