author | sr |
Wed, 17 Jun 2009 18:26:13 +0200 | |
changeset 2171 | 89e49776d439 |
parent 2162 | cec515dece05 |
child 2338 | 7895834d82b4 |
permissions | -rw-r--r-- |
100 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
1164 | 12 |
"{ Package: 'stx:libbasic2' }" |
13 |
||
818 | 14 |
UninterpretedBytes variableByteSubclass:#SocketAddress |
488 | 15 |
instanceVariableNames:'' |
1229 | 16 |
classVariableNames:'DomainToClassMapping' |
488 | 17 |
poolDictionaries:'' |
816 | 18 |
category:'OS-Sockets' |
100 | 19 |
! |
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 | 27 |
!SocketAddress class methodsFor:'documentation'! |
28 |
||
29 |
copyright |
|
30 |
" |
|
31 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
32 |
All Rights Reserved |
|
33 |
||
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
! |
|
42 |
||
43 |
documentation |
|
44 |
" |
|
111 | 45 |
Abstract superclass for subclasses implementing various IPC addressing schemes. |
46 |
See concrete examples IPSocketAddress and UDSocketAddress. |
|
47 |
||
100 | 48 |
ST-80 compatibility class. |
49 |
This may be required when existing code has to be ported to ST/X; |
|
50 |
however, it may not be complete and more protocol may be added in the future. |
|
51 |
The code here was created when public domain code (Manchester) had to |
|
52 |
be ported to ST/X and missing classes/methods were encountered, and code added |
|
53 |
by reasoning 'what the original class could probably do there'. |
|
54 |
||
55 |
This is an additional goody class; therefore: |
|
56 |
||
57 |
THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTOR ``AS IS'' AND |
|
58 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
59 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
60 |
ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTOR BE LIABLE |
|
61 |
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
62 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
63 |
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
64 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
65 |
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
66 |
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
67 |
SUCH DAMAGE. |
|
68 |
" |
|
69 |
! ! |
|
70 |
||
816 | 71 |
!SocketAddress class methodsFor:'instance creation'! |
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 | 112 |
anyHost |
113 |
"get a new instance representing the ANY-host address" |
|
114 |
||
115 |
^ self hostAddress:(self anyAddress) port:0 |
|
116 |
! |
|
117 |
||
1580 | 118 |
fromBytes:bytes |
119 |
"create a socket address from bytes (ByteArray), returned by the |
|
120 |
primitive syscalls" |
|
121 |
||
122 |
|domainSymbol| |
|
123 |
||
124 |
domainSymbol := OperatingSystem domainSymbolOf:(bytes unsignedShortAt:1). |
|
125 |
^ (SocketAddress newDomain:domainSymbol) fromBytes:bytes. |
|
126 |
! |
|
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 | 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 | 138 |
! |
139 |
||
1164 | 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 | 143 |
^ self hostName:name serviceName:nil type:nil. |
144 |
||
145 |
"Modified: / 17-06-2009 / 15:25:42 / sr" |
|
1164 | 146 |
! |
147 |
||
816 | 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 | 151 |
^ self hostName:name serviceName:portNr type:nil |
152 |
! |
|
153 |
||
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 | 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 | 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 | 167 |
]. |
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 | 170 |
|
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 | 173 |
IPSocketAddress hostName:'localhost' serviceName:'echo' type:#datagram |
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 | 178 |
" |
2171 | 179 |
|
180 |
"Modified: / 17-06-2009 / 15:25:35 / sr" |
|
818 | 181 |
! |
182 |
||
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 | 196 |
|
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 | 201 |
AppletalkSocketAddress new |
202 |
" |
|
203 |
! |
|
818 | 204 |
|
1164 | 205 |
newDomain:domain |
206 |
"answer an new socket address for a given domain" |
|
207 |
||
208 |
^ (self knownClassFromCode:domain) new |
|
209 |
||
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 | 217 |
self newDomain:#unix |
218 |
self newDomain:#inet |
|
219 |
" |
|
816 | 220 |
! ! |
221 |
||
1281 | 222 |
!SocketAddress class methodsFor:'addressing'! |
223 |
||
224 |
anyAddress |
|
225 |
self subclassResponsibility |
|
226 |
! ! |
|
227 |
||
100 | 228 |
!SocketAddress class methodsFor:'queries'! |
229 |
||
1164 | 230 |
domainCode |
231 |
"answer the numerical domain code used in socket addresses" |
|
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 | 234 |
! |
235 |
||
100 | 236 |
domainCodeFromName:aNameSymbol |
816 | 237 |
"this is a compatibility method; |
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 | 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 | 322 |
|
100 | 323 |
"/ |
324 |
"/ could someone tell me which symbols are used in ST-80's SocketAddress class ? |
|
325 |
"/ |
|
326 |
self error:'no more mimicri implemented yet ...' |
|
602 | 327 |
|
328 |
"Modified: / 9.1.1998 / 10:03:56 / stefan" |
|
816 | 329 |
! |
330 |
||
331 |
domainNameFromCode:code |
|
332 |
"this is a compatibility method; |
|
333 |
VW expects the internal unix codes here - however, in ST/X, |
|
334 |
symbols are expected - keeping the numeric values secret (in Socket)" |
|
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 | 411 |
|
412 |
"/ |
|
413 |
"/ could someone tell me which symbols are used in ST-80's SocketAddress class ? |
|
414 |
"/ |
|
415 |
self error:'no more mimicri implemented yet ...' |
|
416 |
! |
|
417 |
||
1164 | 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 | 420 |
|
421 |
self == SocketAddress ifTrue:[ |
|
422 |
^ nil |
|
423 |
] ifFalse:[ |
|
424 |
self subclassResponsibility |
|
425 |
] |
|
426 |
! |
|
427 |
||
428 |
getAddressInfo:hostName serviceName:serviceName domain:domainArg type:typeArg protocol:protoArg flags:flags |
|
429 |
"answer an Array of socket addresses for serviceName on hostName |
|
430 |
Domain, type, protocol may be nil or specify a hint for the socket |
|
431 |
addresses to be returned." |
|
432 |
||
433 |
^ OperatingSystem socketAccessor |
|
434 |
getAddressInfo:hostName serviceName:serviceName |
|
435 |
domain:domainArg type:typeArg protocol:protoArg flags:flags |
|
436 |
||
437 |
" |
|
438 |
self getAddressInfo:'localhost' serviceName:nil |
|
439 |
domain:nil type:nil protocol:nil flags:nil |
|
440 |
self getAddressInfo:'localhost' serviceName:nil |
|
441 |
domain:#inet type:#stream protocol:nil flags:nil |
|
442 |
self getAddressInfo:'localhost' serviceName:nil |
|
443 |
domain:#inet type:#stream protocol:#tcp flags:nil |
|
444 |
self getAddressInfo:'blurb.exept.de' serviceName:nil |
|
445 |
domain:#inet type:nil protocol:nil flags:nil |
|
446 |
self getAddressInfo:'1.2.3.4' serviceName:'6' |
|
447 |
domain:#inet type:nil protocol:nil flags:nil |
|
448 |
self getAddressInfo:'localhost' serviceName:'echo' |
|
449 |
domain:#inet6 type:nil protocol:nil flags:nil |
|
450 |
" |
|
451 |
! |
|
452 |
||
1167 | 453 |
getAddressInfo:hostName serviceName:serviceName type:typeArg protocol:protoArg flags:flags |
454 |
"answer an Array of socket addresses for serviceName on hostName |
|
455 |
Domain, type, protocol may be nil or specify a hint for the socket |
|
456 |
addresses to be returned." |
|
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 | 461 |
|
462 |
" |
|
463 |
IPSocketAddress getAddressInfo:'localhost' serviceName:nil |
|
464 |
type:nil protocol:nil flags:nil |
|
465 |
IPSocketAddress getAddressInfo:'localhost' serviceName:nil |
|
466 |
type:#stream protocol:nil flags:nil |
|
467 |
IPSocketAddress getAddressInfo:'localhost' serviceName:nil |
|
468 |
type:#stream protocol:#tcp flags:nil |
|
469 |
IPSocketAddress getAddressInfo:'blurb.exept.de' serviceName:nil |
|
470 |
type:nil protocol:nil flags:nil |
|
471 |
IPSocketAddress getAddressInfo:'1.2.3.4' serviceName:'6' |
|
472 |
type:nil protocol:nil flags:nil |
|
473 |
IPSocketAddress getAddressInfo:'localhost' serviceName:'echo' |
|
474 |
type:nil protocol:nil flags:nil |
|
475 |
" |
|
476 |
! |
|
477 |
||
1164 | 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 | 481 |
|
482 |
^ OperatingSystem socketAccessor |
|
483 |
getNameInfo:socketAddress wantHostName:wantHostName |
|
484 |
wantServiceName:wantServiceName datagram:useDatagram flags:flags |
|
485 |
||
486 |
" |
|
487 |
self getNameInfo: |
|
488 |
(self getAddressInfo:'localhost' serviceName:'echo' |
|
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 | 491 |
" |
492 |
! |
|
493 |
||
816 | 494 |
knownClassFromCode:code |
495 |
"this is a compatibility method; |
|
496 |
VW expects the internal unix codes here - however, in ST/X, |
|
497 |
symbols are expected - keeping the numeric values secret (in Socket)" |
|
498 |
||
1229 | 499 |
|cls| |
500 |
||
501 |
DomainToClassMapping isNil ifTrue:[ |
|
502 |
DomainToClassMapping := IdentityDictionary new |
|
503 |
]. |
|
504 |
cls := DomainToClassMapping at:code ifAbsent:nil. |
|
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 | 515 |
self allSubclassesDo:[:aSubClass| |
516 |
(aSubClass domainCode == code |
|
517 |
or:[aSubClass domainSymbol == code |
|
518 |
or:[aSubClass obsoleteDomainSymbol == code |
|
519 |
or:[aSubClass vwDomainSymbol == code]]]) |
|
520 |
ifTrue:[ |
|
521 |
DomainToClassMapping at:code put:aSubClass. |
|
522 |
^ aSubClass |
|
1226
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
523 |
]. |
1164 | 524 |
]. |
525 |
]. |
|
526 |
^ SocketAddress |
|
816 | 527 |
|
1164 | 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 | 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 | 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 | 542 |
" |
543 |
! |
|
816 | 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 | 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 | 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 | 571 |
! ! |
572 |
||
818 | 573 |
!SocketAddress methodsFor:'accessing'! |
574 |
||
1164 | 575 |
domainCode |
576 |
^ self unsignedShortAt:1 |
|
577 |
! |
|
578 |
||
579 |
domainCode:anInteger |
|
580 |
self unsignedShortAt:1 put:anInteger |
|
581 |
! |
|
582 |
||
1223 | 583 |
hostAddress:addressBytes |
1164 | 584 |
"generic method, subclasses usually redefine this" |
818 | 585 |
|
1223 | 586 |
"/ the first 2-bytes (a short) is the domainCode |
587 |
self replaceBytesFrom:1+2 to:addressBytes size+2 with:addressBytes startingAt:1 |
|
588 |
||
589 |
" |
|
590 |
IPSocketAddress hostAddress:#[193 141 12 193] port:80 |
|
591 |
" |
|
818 | 592 |
! |
593 |
||
1223 | 594 |
hostAddress:addressBytes port:portNr |
595 |
self hostAddress:addressBytes. |
|
818 | 596 |
self port:portNr |
597 |
||
598 |
" |
|
599 |
IPSocketAddress hostAddress:#[193 141 12 193] port:10 |
|
600 |
" |
|
1223 | 601 |
! |
818 | 602 |
|
1934 | 603 |
hostAddressString |
604 |
^ String streamContents:[:s | self printAddressOn:s ]. |
|
605 |
! |
|
606 |
||
1223 | 607 |
port |
608 |
self subclassResponsibility |
|
609 |
! |
|
610 |
||
611 |
port:portNr |
|
612 |
self subclassResponsibility |
|
818 | 613 |
! ! |
614 |
||
1164 | 615 |
!SocketAddress methodsFor:'printing & storing'! |
616 |
||
617 |
displayString |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
618 |
"redefine from Collection" |
1164 | 619 |
|
620 |
|s| |
|
621 |
||
622 |
s := WriteStream on:''. |
|
623 |
self printOn:s. |
|
624 |
^ s contents. |
|
1333 | 625 |
! |
626 |
||
627 |
printAddressOn:arg |
|
628 |
"raise an error: must be redefined in concrete subclass(es)" |
|
629 |
||
630 |
^ self subclassResponsibility |
|
631 |
! |
|
632 |
||
633 |
printOn:aStream |
|
634 |
"append a user printed representation of the receiver to aStream. |
|
635 |
The format is suitable for a human - not meant to be read back." |
|
636 |
||
637 |
self printOn:aStream withPort:true |
|
638 |
! |
|
639 |
||
640 |
printOn:aStream withPort:withPort |
|
641 |
"append a user printed representation of the receiver to aStream. |
|
642 |
The format is suitable for a human - not meant to be read back." |
|
643 |
||
644 |
self printAddressOn:aStream. |
|
645 |
withPort ifTrue:[ |
|
646 |
self printPortOn:aStream. |
|
647 |
]. |
|
648 |
! |
|
649 |
||
650 |
printPortOn:aStream |
|
651 |
|port| |
|
652 |
||
653 |
(port := self port) ~~ 0 ifTrue:[ |
|
654 |
aStream nextPut:$:. |
|
655 |
port printOn:aStream. |
|
656 |
] |
|
1164 | 657 |
! ! |
658 |
||
659 |
!SocketAddress methodsFor:'private'! |
|
660 |
||
661 |
fromBytes:aByteArray |
|
662 |
"Copy the internal representation of a SocketAddress to myself |
|
663 |
||
664 |
This is an internal interface!!" |
|
665 |
||
1225 | 666 |
self replaceBytesFrom:1 to:(self size) with:aByteArray startingAt:1. |
667 |
||
668 |
||
1164 | 669 |
! ! |
670 |
||
100 | 671 |
!SocketAddress methodsFor:'queries'! |
672 |
||
488 | 673 |
address |
674 |
^ self subclassResponsibility |
|
675 |
! |
|
676 |
||
111 | 677 |
hostName |
1164 | 678 |
^ (self class getNameInfo:self wantHostName:true |
679 |
wantServiceName:false datagram:false flags:0) first |
|
111 | 680 |
|
1164 | 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 | 689 |
" |
111 | 690 |
! |
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 | 710 |
portOrName |
210 | 711 |
^ self subclassResponsibility |
1164 | 712 |
! |
713 |
||
714 |
serviceName |
|
715 |
^ (self class getNameInfo:self wantHostName:false |
|
716 |
wantServiceName:true datagram:false flags:0) second |
|
717 |
||
718 |
" |
|
719 |
(IPSocketAddress hostAddress:#[127 0 0 1] port:7) serviceName |
|
720 |
(IPSocketAddress hostAddress:#[193 141 12 193] port:10) serviceName |
|
721 |
" |
|
100 | 722 |
! ! |
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 | 732 |
!SocketAddress class methodsFor:'documentation'! |
733 |
||
734 |
version |
|
2171 | 735 |
^ '$Header: /cvs/stx/stx/libbasic2/SocketAddress.st,v 1.31 2009-06-17 16:26:13 sr Exp $' |
488 | 736 |
! ! |