author | Claus Gittinger <cg@exept.de> |
Tue, 25 Jun 2019 11:09:04 +0200 | |
changeset 5048 | 63f42cfbaf59 |
parent 4670 | a23c3ec06b51 |
permissions | -rw-r--r-- |
4670 | 1 |
"{ Encoding: utf8 }" |
2 |
||
100 | 3 |
" |
4 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
1164 | 14 |
"{ Package: 'stx:libbasic2' }" |
15 |
||
3466 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
818 | 18 |
UninterpretedBytes variableByteSubclass:#SocketAddress |
488 | 19 |
instanceVariableNames:'' |
2339 | 20 |
classVariableNames:'DomainToClassMapping Verbose LastName LastPort LastType LastAddr |
21 |
LastTime' |
|
488 | 22 |
poolDictionaries:'' |
816 | 23 |
category:'OS-Sockets' |
100 | 24 |
! |
25 |
||
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
26 |
!SocketAddress primitiveDefinitions! |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
27 |
%{ |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
28 |
#include "stxOSDefs.h" |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
29 |
%} |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
30 |
! ! |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
31 |
|
100 | 32 |
!SocketAddress class methodsFor:'documentation'! |
33 |
||
34 |
copyright |
|
35 |
" |
|
36 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
37 |
All Rights Reserved |
|
38 |
||
39 |
This software is furnished under a license and may be used |
|
40 |
only in accordance with the terms of that license and with the |
|
41 |
inclusion of the above copyright notice. This software may not |
|
42 |
be provided or otherwise made available to, or used by, any |
|
43 |
other person. No title to or ownership of the software is |
|
44 |
hereby transferred. |
|
45 |
" |
|
46 |
! |
|
47 |
||
48 |
documentation |
|
49 |
" |
|
111 | 50 |
Abstract superclass for subclasses implementing various IPC addressing schemes. |
51 |
See concrete examples IPSocketAddress and UDSocketAddress. |
|
52 |
||
100 | 53 |
ST-80 compatibility class. |
54 |
This may be required when existing code has to be ported to ST/X; |
|
55 |
however, it may not be complete and more protocol may be added in the future. |
|
56 |
The code here was created when public domain code (Manchester) had to |
|
57 |
be ported to ST/X and missing classes/methods were encountered, and code added |
|
58 |
by reasoning 'what the original class could probably do there'. |
|
59 |
||
60 |
This is an additional goody class; therefore: |
|
61 |
||
62 |
THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTOR ``AS IS'' AND |
|
63 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
64 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
65 |
ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTOR BE LIABLE |
|
66 |
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
67 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
68 |
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
69 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
70 |
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
71 |
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
72 |
SUCH DAMAGE. |
|
73 |
" |
|
74 |
! ! |
|
75 |
||
816 | 76 |
!SocketAddress class methodsFor:'instance creation'! |
77 |
||
1910
92504f2834ce
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1895
diff
changeset
|
78 |
allForHostName:name |
92504f2834ce
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1895
diff
changeset
|
79 |
"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
|
80 |
|
4340 | 81 |
^ self allForHostName:name serviceName:nil type:#stream. |
82 |
||
83 |
"Modified: / 21-02-2017 / 21:17:21 / stefan" |
|
1910
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 |
|
92504f2834ce
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1895
diff
changeset
|
86 |
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
|
87 |
"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
|
88 |
|
4340 | 89 |
^ self allForHostName:name serviceName:portNr domain:nil type:nil |
90 |
||
91 |
"Modified: / 21-02-2017 / 21:40:19 / stefan" |
|
1910
92504f2834ce
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1895
diff
changeset
|
92 |
! |
92504f2834ce
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1895
diff
changeset
|
93 |
|
4340 | 94 |
allForHostName:name serviceName:portNrOrName domain:domainSymbol type:socketTypeSymbol |
1910
92504f2834ce
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1895
diff
changeset
|
95 |
"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
|
96 |
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
|
97 |
|
4340 | 98 |
^ (self |
99 |
getAddressInfo:name |
|
100 |
serviceName:portNrOrName |
|
101 |
domain:domainSymbol |
|
102 |
type:socketTypeSymbol |
|
103 |
protocol:nil |
|
104 |
flags:0 |
|
105 |
) 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
|
106 |
|
92504f2834ce
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1895
diff
changeset
|
107 |
|
92504f2834ce
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1895
diff
changeset
|
108 |
" |
92504f2834ce
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1895
diff
changeset
|
109 |
SocketAddress allForHostName:'localhost' serviceName:10 type:#stream |
1914
8a6e5feaeaef
simplified numeric port handling in #allForHostname:...
Stefan Vogel <sv@exept.de>
parents:
1910
diff
changeset
|
110 |
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
|
111 |
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
|
112 |
IPSocketAddress allForHostName:'localhost' serviceName:'echo' type:nil |
4340 | 113 |
SocketAddress allForHostName:'google.com' serviceName:'http' type:#stream |
1910
92504f2834ce
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1895
diff
changeset
|
114 |
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
|
115 |
" |
4340 | 116 |
|
117 |
"Created: / 21-02-2017 / 21:34:25 / stefan" |
|
118 |
! |
|
119 |
||
120 |
allForHostName:name serviceName:portNrOrName type:socketTypeSymbol |
|
121 |
"get a collection of new instances given a hostname, port or service and type. |
|
122 |
Multi-homed hosts return more than one entry" |
|
123 |
||
124 |
^ self allForHostName:name serviceName:portNrOrName domain:self domain type:socketTypeSymbol |
|
125 |
||
126 |
" |
|
127 |
SocketAddress allForHostName:'localhost' serviceName:10 type:#stream |
|
128 |
SocketAddress allForHostName:'localhost' serviceName:'10' type:#stream |
|
129 |
IPSocketAddress allForHostName:'localhost' serviceName:'echo' type:#datagram |
|
130 |
IPSocketAddress allForHostName:'localhost' serviceName:'echo' type:nil |
|
131 |
SocketAddress allForHostName:'google.com' serviceName:'http' type:#stream |
|
132 |
IPSocketAddress allForHostName:'google.com' serviceName:'http' type:nil |
|
133 |
" |
|
134 |
||
135 |
"Modified: / 21-02-2017 / 21:35:17 / stefan" |
|
1910
92504f2834ce
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1895
diff
changeset
|
136 |
! |
92504f2834ce
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1895
diff
changeset
|
137 |
|
1281 | 138 |
anyHost |
139 |
"get a new instance representing the ANY-host address" |
|
140 |
||
3071 | 141 |
^ self hostAddress:self anyAddress |
1281 | 142 |
! |
143 |
||
3290 | 144 |
fromBytes:bytesArg |
3286 | 145 |
"create a socket address from bytes (ByteArray), |
146 |
returned by the primitive syscalls. |
|
147 |
Raises an error, if the domainType is not supported by this Smalltalk |
|
148 |
(i.e. if libbasic was compiled without support for the corresponding AF_xxx support)" |
|
149 |
||
3290 | 150 |
|domainNr domainSymbol bytes| |
151 |
||
152 |
bytes := bytesArg asByteArray. |
|
1580 | 153 |
|
3290 | 154 |
"/ cg: code used to be: |
155 |
"/ domainNr := bytes unsignedShortAt:1. |
|
156 |
"/ however, some systems use a different structure, which includes the struct length |
|
157 |
"/ in byte 1 (APPLE). |
|
158 |
"/ so better let the C-compiler figure out how things are layed out... |
|
159 |
%{ |
|
160 |
if (__isByteArrayLike(bytes)) { |
|
161 |
struct sockaddr *s = (struct sockaddr *)(__ByteArrayInstPtr(bytes)->ba_element); |
|
162 |
||
163 |
domainNr = __mkSmallInteger(s->sa_family); |
|
164 |
} |
|
165 |
%}. |
|
3286 | 166 |
domainSymbol := OperatingSystem domainSymbolOf:domainNr. |
167 |
domainSymbol isNil ifTrue:[ |
|
168 |
self error:('unsupported domain (type=%1)' bindWith:domainNr) |
|
169 |
]. |
|
170 |
^ (SocketAddress newDomain:domainSymbol) fromBytes:bytes. |
|
1580 | 171 |
! |
172 |
||
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
173 |
hostAddress:addr |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
174 |
"get a new instance given addr-bytes" |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
175 |
|
3071 | 176 |
^ self new hostAddress:addr |
4670 | 177 |
|
178 |
" |
|
179 |
IPSocketAddress hostAddress:#[127 0 0 1] |
|
180 |
" |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
181 |
! |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
182 |
|
816 | 183 |
hostAddress:addr port:portNr |
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
184 |
"get a new instance given addr-bytes and a portNr" |
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 new hostAddress:addr; port:portNr |
816 | 187 |
! |
188 |
||
1164 | 189 |
hostName:name |
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
190 |
"get a new instance given a hostname" |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
191 |
|
2171 | 192 |
^ self hostName:name serviceName:nil type:nil. |
193 |
||
194 |
"Modified: / 17-06-2009 / 15:25:42 / sr" |
|
1164 | 195 |
! |
196 |
||
816 | 197 |
hostName:name port:portNr |
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
198 |
"get a new instance given a hostname and port" |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
199 |
|
2460 | 200 |
"Solaris 9 has a problem with some service names if type is missing!!" |
201 |
^ self hostName:name serviceName:portNr type:#SOCK_STREAM |
|
1164 | 202 |
! |
203 |
||
204 |
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
|
205 |
"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
|
206 |
Do not use this, since it does not work for multi-homed hosts" |
1164 | 207 |
|
1910
92504f2834ce
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1895
diff
changeset
|
208 |
|addressList sa| |
1164 | 209 |
|
2338 | 210 |
LastName = name ifTrue:[ |
211 |
LastPort = portNrOrName ifTrue:[ |
|
212 |
LastType = socketTypeSymbol ifTrue:[ |
|
3227 | 213 |
(Timestamp now secondDeltaFrom: LastTime) <= 30 ifTrue:[ |
2339 | 214 |
^ LastAddr |
215 |
] |
|
2338 | 216 |
] |
217 |
] |
|
218 |
]. |
|
219 |
||
1910
92504f2834ce
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1895
diff
changeset
|
220 |
addressList := self allForHostName:name serviceName:portNrOrName type:socketTypeSymbol. |
3583 | 221 |
addressList isNil ifTrue:[^ nil]. |
222 |
||
2162
cec515dece05
return the last socketAddress from a multi-list, instead of the first
Michael Beyl <mb@exept.de>
parents:
1934
diff
changeset
|
223 |
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
|
224 |
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
|
225 |
(addressList contains:[:entry| entry ~= sa]) ifTrue:[ |
2338 | 226 |
Verbose == true ifTrue:[ |
227 |
('SocketAddress [warning]: multiple hostAddresses for host: ', name) infoPrintCR. |
|
228 |
addressList do:[:entry| ' ' infoPrint. entry infoPrintCR]. |
|
229 |
(addressList detect:[:entry| entry ~= sa] ifNone:nil) infoPrintCR. |
|
230 |
]. |
|
1164 | 231 |
]. |
232 |
]. |
|
2339 | 233 |
LastTime := Timestamp now. |
2338 | 234 |
LastName := name. |
235 |
LastPort := portNrOrName. |
|
236 |
LastType := socketTypeSymbol. |
|
237 |
LastAddr := sa. |
|
1910
92504f2834ce
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1895
diff
changeset
|
238 |
^ sa. |
1164 | 239 |
|
240 |
" |
|
2162
cec515dece05
return the last socketAddress from a multi-list, instead of the first
Michael Beyl <mb@exept.de>
parents:
1934
diff
changeset
|
241 |
SocketAddress hostName:'localhost' serviceName:10 type:#stream |
1164 | 242 |
IPSocketAddress hostName:'localhost' serviceName:'echo' type:#datagram |
243 |
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
|
244 |
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
|
245 |
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
|
246 |
SocketAddress allForHostName:'www.google.com' serviceName:10 type:#stream. |
1164 | 247 |
" |
2171 | 248 |
|
249 |
"Modified: / 17-06-2009 / 15:25:35 / sr" |
|
818 | 250 |
! |
251 |
||
252 |
new |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
253 |
|numBytes| |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
254 |
|
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
255 |
self == SocketAddress ifTrue:[ |
2849 | 256 |
self abstractClassInstantiationError. |
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
257 |
]. |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
258 |
|
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
259 |
numBytes := self socketAddressSize. |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
260 |
numBytes isNil ifTrue:[ |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
261 |
self error:'unsupported domain'. |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
262 |
^ nil |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
263 |
]. |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
264 |
^ (self new:numBytes) domainCode:(self domainCode) |
1164 | 265 |
|
266 |
" |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
267 |
IPSocketAddress new |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
268 |
IPv6SocketAddress new |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
269 |
UDSocketAddress new |
1164 | 270 |
AppletalkSocketAddress new |
271 |
" |
|
272 |
! |
|
818 | 273 |
|
1164 | 274 |
newDomain:domain |
275 |
"answer an new socket address for a given domain" |
|
276 |
||
277 |
^ (self knownClassFromCode:domain) new |
|
278 |
||
279 |
" |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
280 |
self newDomain:#afUnix |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
281 |
self newDomain:#afInet |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
282 |
|
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
283 |
self newDomain:#'AF_UNIX' |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
284 |
self newDomain:#'AF_INET' |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
285 |
|
1164 | 286 |
self newDomain:#unix |
287 |
self newDomain:#inet |
|
288 |
" |
|
816 | 289 |
! ! |
290 |
||
1281 | 291 |
!SocketAddress class methodsFor:'addressing'! |
292 |
||
293 |
anyAddress |
|
294 |
self subclassResponsibility |
|
295 |
! ! |
|
296 |
||
100 | 297 |
!SocketAddress class methodsFor:'queries'! |
298 |
||
3055
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
299 |
domain |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
300 |
"Answer the domain symbol. Subclasses redefine this" |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
301 |
|
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
302 |
self == SocketAddress ifTrue:[ |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
303 |
^ nil |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
304 |
] ifFalse:[ |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
305 |
self subclassResponsibility |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
306 |
] |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
307 |
! |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
308 |
|
1164 | 309 |
domainCode |
310 |
"answer the numerical domain code used in socket addresses" |
|
311 |
||
3055
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
312 |
^ OperatingSystem domainCodeOf:self domain |
1164 | 313 |
! |
314 |
||
100 | 315 |
domainCodeFromName:aNameSymbol |
816 | 316 |
"this is a compatibility method; |
317 |
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
|
318 |
symbols are returned, which are translated later" |
816 | 319 |
|
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
320 |
aNameSymbol isInteger ifTrue:[ ^ aNameSymbol ]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
321 |
|
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
322 |
"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
|
323 |
which are handled by the primitives" |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
324 |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
325 |
aNameSymbol == #afUnix ifTrue:[^ #'AF_UNIX']. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
326 |
aNameSymbol == #AF_UNIX ifTrue:[^ #'AF_UNIX']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
327 |
aNameSymbol == #unix ifTrue:[^ #'AF_UNIX']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
328 |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
329 |
aNameSymbol == #afInet ifTrue:[^ #'AF_INET']. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
330 |
aNameSymbol == #'AF_INET' ifTrue:[^ #'AF_INET']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
331 |
aNameSymbol == #inet ifTrue:[^ #'AF_INET']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
332 |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
333 |
aNameSymbol == #afIpV6 ifTrue:[^ #'AF_INET6']. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
334 |
aNameSymbol == #'AF_INET6' ifTrue:[^ #'AF_INET6']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
335 |
aNameSymbol == #inet6 ifTrue:[^ #'AF_INET6']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
336 |
aNameSymbol == #afInet6 ifTrue:[^ #'AF_INET6']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
337 |
|
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
338 |
aNameSymbol == #afAppletalk ifTrue:[^ #'AF_APPLETALK']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
339 |
aNameSymbol == #'AF_APPLETALK' ifTrue:[^ #'AF_APPLETALK']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
340 |
aNameSymbol == #appletalk ifTrue:[^ #'AF_APPLETALK']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
341 |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
342 |
aNameSymbol == #afDecnet ifTrue:[^ #'AF_DECnet']. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
343 |
aNameSymbol == #'AF_DECnet' ifTrue:[^ #'AF_DECnet']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
344 |
aNameSymbol == #'AF_DECNET' ifTrue:[^ #'AF_DECnet']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
345 |
aNameSymbol == #decnet ifTrue:[^ #'AF_DECnet']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
346 |
aNameSymbol == #decNet ifTrue:[^ #'AF_DECnet']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
347 |
aNameSymbol == #DECnet ifTrue:[^ #'AF_DECnet']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
348 |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
349 |
aNameSymbol == #afSna ifTrue:[^ #'AF_SNA']. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
350 |
aNameSymbol == #'AF_SNA' ifTrue:[^ #'AF_SNA']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
351 |
aNameSymbol == #sna ifTrue:[^ #'AF_SNA']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
352 |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
353 |
aNameSymbol == #afNs ifTrue:[^ #'AF_NS']. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
354 |
aNameSymbol == #'AF_NS' ifTrue:[^ #'AF_NS']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
355 |
aNameSymbol == #ns ifTrue:[^ #'AF_NS']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
356 |
aNameSymbol == #xns ifTrue:[^ #'AF_NS']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
357 |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
358 |
aNameSymbol == #afCcitt ifTrue:[^ #'AF_CCITT']. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
359 |
aNameSymbol == #'AF_CCITT' ifTrue:[^ #'AF_CCITT']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
360 |
aNameSymbol == #ccitt ifTrue:[^ #'AF_CCITT']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
361 |
|
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
362 |
aNameSymbol == #afImplink ifTrue:[^ #'AF_IMPLINK']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
363 |
aNameSymbol == #'AF_IMPLINK' ifTrue:[^ #'AF_IMPLINK']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
364 |
aNameSymbol == #implink ifTrue:[^ #'AF_IMPLINK']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
365 |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
366 |
aNameSymbol == #afPup ifTrue:[^ #'AF_PUP']. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
367 |
aNameSymbol == #'AF_PUP' ifTrue:[^ #'AF_PUP']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
368 |
aNameSymbol == #pup ifTrue:[^ #'AF_PUP']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
369 |
|
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
370 |
aNameSymbol == #afChaos ifTrue:[^ #'AF_CHAOS']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
371 |
aNameSymbol == #'AF_CHAOS' ifTrue:[^ #'AF_CHAOS']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
372 |
aNameSymbol == #chaos ifTrue:[^ #'AF_CHAOS']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
373 |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
374 |
aNameSymbol == #afEcma ifTrue:[^ #'AF_ECMA']. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
375 |
aNameSymbol == #'AF_ECMA' ifTrue:[^ #'AF_ECMA']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
376 |
aNameSymbol == #ecma ifTrue:[^ #'AF_ECMA']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
377 |
|
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
378 |
aNameSymbol == #afDatakit ifTrue:[^ #'AF_DATAKIT']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
379 |
aNameSymbol == #'AF_DATAKIT' ifTrue:[^ #'AF_DATAKIT']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
380 |
aNameSymbol == #datakit ifTrue:[^ #'AF_DATAKIT']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
381 |
|
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
382 |
aNameSymbol == #afDli ifTrue:[^ #'AF_DLI']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
383 |
aNameSymbol == #'AF_DLI' ifTrue:[^ #'AF_DLI']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
384 |
aNameSymbol == #dli ifTrue:[^ #'AF_DLI']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
385 |
|
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
386 |
aNameSymbol == #afLat ifTrue:[^ #'AF_LAT']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
387 |
aNameSymbol == #'AF_LAT' ifTrue:[^ #'AF_LAT']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
388 |
aNameSymbol == #lat ifTrue:[^ #'AF_LAT']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
389 |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
390 |
aNameSymbol == #afHylink ifTrue:[^ #'AF_HYLINK']. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
391 |
aNameSymbol == #'AF_HYLINK' ifTrue:[^ #'AF_HYLINK']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
392 |
aNameSymbol == #hylink ifTrue:[^ #'AF_HYLINK']. |
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
393 |
|
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
394 |
aNameSymbol == #afUnspec ifTrue:[^ #'AF_UNSPEC']. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
395 |
aNameSymbol == #'AF_UNSPEC' ifTrue:[^ #'AF_UNSPEC']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
396 |
aNameSymbol == #unspec ifTrue:[^ #'AF_UNSPEC']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
397 |
|
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
398 |
aNameSymbol == #afRaw ifTrue:[^ #'AF_RAW']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
399 |
aNameSymbol == #'AF_RAW' ifTrue:[^ #'AF_RAW']. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
400 |
aNameSymbol == #raw ifTrue:[^ #'AF_RAW']. |
816 | 401 |
|
100 | 402 |
"/ |
403 |
"/ could someone tell me which symbols are used in ST-80's SocketAddress class ? |
|
404 |
"/ |
|
405 |
self error:'no more mimicri implemented yet ...' |
|
602 | 406 |
|
407 |
"Modified: / 9.1.1998 / 10:03:56 / stefan" |
|
816 | 408 |
! |
409 |
||
410 |
domainNameFromCode:code |
|
411 |
"this is a compatibility method; |
|
412 |
VW expects the internal unix codes here - however, in ST/X, |
|
413 |
symbols are expected - keeping the numeric values secret (in Socket)" |
|
414 |
||
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
415 |
code == #unix ifTrue:[^ #afUnix]. |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
416 |
code == #'AF_UNIX' ifTrue:[^ #afUnix]. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
417 |
code == #'afUnix' ifTrue:[^ #afUnix]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
418 |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
419 |
code == #inet ifTrue:[^ #afInet]. |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
420 |
code == #'AF_INET' ifTrue:[^ #afInet]. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
421 |
code == #'afInet' ifTrue:[^ #afInet]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
422 |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
423 |
code == #inet6 ifTrue:[^ #afIpV6]. |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
424 |
code == #'AF_INET6' ifTrue:[^ #afIpV6]. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
425 |
code == #'afIpV6' ifTrue:[^ #afIpV6]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
426 |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
427 |
code == #appletalk ifTrue:[^ #afAppletalk]. |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
428 |
code == #'AF_APPLETALK' ifTrue:[^ #afAppletalk]. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
429 |
code == #'afAppletalk' ifTrue:[^ #afAppletalk]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
430 |
|
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
431 |
code == #decnet ifTrue:[^ #afDecnet]. |
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
432 |
code == #DECnet ifTrue:[^ #afDecnet]. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
433 |
code == #decNet ifTrue:[^ #afDecnet]. |
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
434 |
code == #'AF_DECNET' ifTrue:[^ #afDecnet]. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
435 |
code == #'AF_DECnet' ifTrue:[^ #afDecnet]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
436 |
code == #'afDecnet' ifTrue:[^ #afDecnet]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
437 |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
438 |
code == #sna ifTrue:[^ #afSna]. |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
439 |
code == #'AF_SNA' ifTrue:[^ #afSna]. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
440 |
code == #'afSna' ifTrue:[^ #afSna]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
441 |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
442 |
code == #xns ifTrue:[^ #afNs]. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
443 |
code == #ns ifTrue:[^ #afNs]. |
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
444 |
code == #'AF_NS' ifTrue:[^ #afNs]. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
445 |
code == #'afNs' ifTrue:[^ #afNs]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
446 |
|
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
447 |
code == #ccitt ifTrue:[^ #afCcitt]. |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
448 |
code == #'AF_CCITT' ifTrue:[^ #afCcitt]. |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
449 |
code == #'afCcitt' ifTrue:[^ #afCcitt]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
450 |
|
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
451 |
code == #implink ifTrue:[^ #afImplink]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
452 |
code == #'AF_IMPLINK' ifTrue:[^ #afImplink]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
453 |
code == #afImplink ifTrue:[^ #afImplink]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
454 |
|
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
455 |
code == #pup ifTrue:[^ #afPup]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
456 |
code == #'AF_PUP' ifTrue:[^ #afPup]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
457 |
code == #afPup ifTrue:[^ #afPup]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
458 |
|
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
459 |
code == #chaos ifTrue:[^ #afChaos]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
460 |
code == #'AF_CHAOS' ifTrue:[^ #afChaos]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
461 |
code == #afChaos ifTrue:[^ #afChaos]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
462 |
|
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
463 |
code == #ecma ifTrue:[^ #afEcma]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
464 |
code == #'AF_ECMA' ifTrue:[^ #afEcma]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
465 |
code == #afEcma ifTrue:[^ #afEcma]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
466 |
|
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
467 |
code == #datakit ifTrue:[^ #afDatakit]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
468 |
code == #'AF_DATAKIT' ifTrue:[^ #afDatakit]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
469 |
code == #afDatakit ifTrue:[^ #afDatakit]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
470 |
|
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
471 |
code == #dli ifTrue:[^ #afDli]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
472 |
code == #'AF_DLI' ifTrue:[^ #afDli]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
473 |
code == #afDli ifTrue:[^ #afDli]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
474 |
|
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
475 |
code == #lat ifTrue:[^ #afLat]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
476 |
code == #'AF_LAT' ifTrue:[^ #afLat]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
477 |
code == #afLat ifTrue:[^ #afLat]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
478 |
|
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
479 |
code == #hylink ifTrue:[^ #afHylink]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
480 |
code == #'AF_HYLINK' ifTrue:[^ #afHylink]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
481 |
code == #afHylink ifTrue:[^ #afHylink]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
482 |
|
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
483 |
code == #unspec ifTrue:[^ #afUnspec]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
484 |
code == #'AF_UNSPEC' ifTrue:[^ #afUnspec]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
485 |
code == #afUnspec ifTrue:[^ #afUnspec]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
486 |
|
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
487 |
code == #raw ifTrue:[^ #afRaw]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
488 |
code == #'AF_RAW' ifTrue:[^ #afRaw]. |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
489 |
code == #afRaw ifTrue:[^ #afRaw]. |
816 | 490 |
|
491 |
"/ |
|
492 |
"/ could someone tell me which symbols are used in ST-80's SocketAddress class ? |
|
493 |
"/ |
|
494 |
self error:'no more mimicri implemented yet ...' |
|
495 |
! |
|
496 |
||
1164 | 497 |
getAddressInfo:hostName serviceName:serviceName domain:domainArg type:typeArg protocol:protoArg flags:flags |
498 |
"answer an Array of socket addresses for serviceName on hostName |
|
499 |
Domain, type, protocol may be nil or specify a hint for the socket |
|
500 |
addresses to be returned." |
|
501 |
||
502 |
^ OperatingSystem socketAccessor |
|
503 |
getAddressInfo:hostName serviceName:serviceName |
|
504 |
domain:domainArg type:typeArg protocol:protoArg flags:flags |
|
505 |
||
506 |
" |
|
507 |
self getAddressInfo:'localhost' serviceName:nil |
|
508 |
domain:nil type:nil protocol:nil flags:nil |
|
509 |
self getAddressInfo:'localhost' serviceName:nil |
|
3076 | 510 |
domain:#AF_INET type:#stream protocol:nil flags:nil |
1164 | 511 |
self getAddressInfo:'localhost' serviceName:nil |
3076 | 512 |
domain:#AF_INET type:#stream protocol:#tcp flags:nil |
1164 | 513 |
self getAddressInfo:'blurb.exept.de' serviceName:nil |
3076 | 514 |
domain:#AF_INET type:nil protocol:nil flags:nil |
1164 | 515 |
self getAddressInfo:'1.2.3.4' serviceName:'6' |
3076 | 516 |
domain:#AF_INET type:nil protocol:nil flags:nil |
1164 | 517 |
self getAddressInfo:'localhost' serviceName:'echo' |
3076 | 518 |
domain:#AF_INET6 type:nil protocol:nil flags:nil |
1164 | 519 |
" |
520 |
! |
|
521 |
||
1167 | 522 |
getAddressInfo:hostName serviceName:serviceName type:typeArg protocol:protoArg flags:flags |
523 |
"answer an Array of socket addresses for serviceName on hostName |
|
524 |
Domain, type, protocol may be nil or specify a hint for the socket |
|
525 |
addresses to be returned." |
|
526 |
||
1232
49ce4681f1c0
dont wine if we get multiple host addresses for a name
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
527 |
^ self |
49ce4681f1c0
dont wine if we get multiple host addresses for a name
Claus Gittinger <cg@exept.de>
parents:
1229
diff
changeset
|
528 |
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
|
529 |
domain:(self domainCode) type:typeArg protocol:protoArg flags:flags |
1167 | 530 |
|
531 |
" |
|
532 |
IPSocketAddress getAddressInfo:'localhost' serviceName:nil |
|
533 |
type:nil protocol:nil flags:nil |
|
534 |
IPSocketAddress getAddressInfo:'localhost' serviceName:nil |
|
535 |
type:#stream protocol:nil flags:nil |
|
536 |
IPSocketAddress getAddressInfo:'localhost' serviceName:nil |
|
537 |
type:#stream protocol:#tcp flags:nil |
|
538 |
IPSocketAddress getAddressInfo:'blurb.exept.de' serviceName:nil |
|
539 |
type:nil protocol:nil flags:nil |
|
540 |
IPSocketAddress getAddressInfo:'1.2.3.4' serviceName:'6' |
|
541 |
type:nil protocol:nil flags:nil |
|
542 |
IPSocketAddress getAddressInfo:'localhost' serviceName:'echo' |
|
543 |
type:nil protocol:nil flags:nil |
|
544 |
" |
|
545 |
! |
|
546 |
||
1164 | 547 |
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
|
548 |
"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
|
549 |
for a given socketAddress." |
1164 | 550 |
|
551 |
^ OperatingSystem socketAccessor |
|
552 |
getNameInfo:socketAddress wantHostName:wantHostName |
|
553 |
wantServiceName:wantServiceName datagram:useDatagram flags:flags |
|
554 |
||
555 |
" |
|
556 |
self getNameInfo: |
|
557 |
(self getAddressInfo:'localhost' serviceName:'echo' |
|
558 |
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
|
559 |
wantHostName:true wantServiceName:true datagram:false flags:0 |
1164 | 560 |
" |
561 |
! |
|
562 |
||
3047 | 563 |
hostAddressLen |
564 |
"answer the number of bytes of the host address" |
|
565 |
||
566 |
^ self subclassResponsibility |
|
567 |
! |
|
568 |
||
4313 | 569 |
isAbstract |
570 |
"Return if this class is an abstract class. |
|
571 |
True is returned here for myself only; false for subclasses. |
|
572 |
Abstract subclasses must redefine this again." |
|
573 |
||
574 |
^ self == SocketAddress. |
|
575 |
! |
|
576 |
||
816 | 577 |
knownClassFromCode:code |
578 |
"this is a compatibility method; |
|
579 |
VW expects the internal unix codes here - however, in ST/X, |
|
580 |
symbols are expected - keeping the numeric values secret (in Socket)" |
|
581 |
||
1229 | 582 |
|cls| |
583 |
||
584 |
DomainToClassMapping isNil ifTrue:[ |
|
3055
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
585 |
DomainToClassMapping := IdentityDictionary new. |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
586 |
"/ some are always known... |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
587 |
DomainToClassMapping |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
588 |
at:#unix put:UDSocketAddress; |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
589 |
at:#inet put:IPSocketAddress; |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
590 |
at:#inet6 put:IPv6SocketAddress; |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
591 |
at:#appletalk put:AppletalkSocketAddress; |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
592 |
at:#decnet put:DecNetSocketAddress. |
1229 | 593 |
]. |
594 |
cls := DomainToClassMapping at:code ifAbsent:nil. |
|
595 |
cls notNil ifTrue:[^ cls]. |
|
1259
0a557e59ea4a
instance creation refactored
Claus Gittinger <cg@exept.de>
parents:
1232
diff
changeset
|
596 |
|
1226
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
597 |
code notNil ifTrue:[ |
1229 | 598 |
self allSubclassesDo:[:aSubClass| |
599 |
(aSubClass domainCode == code |
|
3055
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
600 |
or:[aSubClass domain == code |
1229 | 601 |
or:[aSubClass obsoleteDomainSymbol == code |
602 |
or:[aSubClass vwDomainSymbol == code]]]) |
|
603 |
ifTrue:[ |
|
604 |
DomainToClassMapping at:code put:aSubClass. |
|
605 |
^ aSubClass |
|
1226
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
606 |
]. |
1164 | 607 |
]. |
608 |
]. |
|
609 |
^ SocketAddress |
|
816 | 610 |
|
1164 | 611 |
" |
1273
03afdf3f895e
addrCache and nameCache must be separate for
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
612 |
DomainToClassMapping := nil. |
03afdf3f895e
addrCache and nameCache must be separate for
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
613 |
|
1229 | 614 |
self knownClassFromCode:#'AF_UNIX' |
1226
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
615 |
self knownClassFromCode:#'AF_INET' |
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
616 |
|
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
617 |
self knownClassFromCode:1 |
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
618 |
self knownClassFromCode:2 |
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
619 |
|
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
620 |
self knownClassFromCode:#unix obsolete ST/X codes |
1164 | 621 |
self knownClassFromCode:#inet |
1226
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
622 |
|
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
623 |
self knownClassFromCode:#afUnix visualWorks codes |
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
624 |
self knownClassFromCode:#afInet |
1164 | 625 |
" |
626 |
! |
|
816 | 627 |
|
1226
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
628 |
obsoleteDomainSymbol |
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
629 |
^ nil |
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
630 |
! |
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
631 |
|
1259
0a557e59ea4a
instance creation refactored
Claus Gittinger <cg@exept.de>
parents:
1232
diff
changeset
|
632 |
peerNameFromPeer:peer |
0a557e59ea4a
instance creation refactored
Claus Gittinger <cg@exept.de>
parents:
1232
diff
changeset
|
633 |
^ peer hostName |
0a557e59ea4a
instance creation refactored
Claus Gittinger <cg@exept.de>
parents:
1232
diff
changeset
|
634 |
! |
0a557e59ea4a
instance creation refactored
Claus Gittinger <cg@exept.de>
parents:
1232
diff
changeset
|
635 |
|
1164 | 636 |
socketAddressSize |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
637 |
"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
|
638 |
Returns nil, if the domain is not supported or invalid." |
1164 | 639 |
|
3055
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
640 |
^ OperatingSystem socketAddressSizeOfDomain:self domain |
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
641 |
|
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
642 |
" |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
643 |
SocketAddress socketAddressSize |
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
644 |
UDSocketAddress socketAddressSize |
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
645 |
IPSocketAddress socketAddressSize |
1279
13ccd72f5f5d
moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents:
1273
diff
changeset
|
646 |
IPv6SocketAddress socketAddressSize |
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
647 |
AppletalkSocketAddress socketAddressSize |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
648 |
DecNetSocketAddress socketAddressSize |
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
649 |
" |
1226
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
650 |
! |
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
651 |
|
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
652 |
vwDomainSymbol |
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1225
diff
changeset
|
653 |
^ nil |
100 | 654 |
! ! |
655 |
||
818 | 656 |
!SocketAddress methodsFor:'accessing'! |
657 |
||
1164 | 658 |
domainCode |
3466 | 659 |
"this opaquely returns the first two bytes as a short integer; |
660 |
Notice: some systems store the domainCode in those 2 bytes, |
|
661 |
whereas others (IOS) store the size of the addr-struct in byte 1, |
|
662 |
and the actual domain code in byte 2" |
|
663 |
||
664 |
OperatingSystem isOSXlike ifTrue:[ |
|
665 |
^ self at:2 |
|
666 |
]. |
|
3770 | 667 |
^ self unsignedInt16At:1 |
1164 | 668 |
! |
669 |
||
670 |
domainCode:anInteger |
|
3466 | 671 |
"this opaquely sets the first two bytes as a short integer; |
672 |
Notice: some systems store the domainCode in those 2 bytes, |
|
673 |
whereas others (IOS) store the size of the addr-struct in byte 1, |
|
674 |
and the actual domain code in byte 2" |
|
675 |
||
676 |
OperatingSystem isOSXlike ifTrue:[ |
|
677 |
self at:1 put:self size. |
|
678 |
self at:2 put:anInteger. |
|
679 |
] ifFalse:[ |
|
3770 | 680 |
self unsignedInt16At:1 put:anInteger |
3466 | 681 |
]. |
1164 | 682 |
! |
683 |
||
1223 | 684 |
hostAddress:addressBytes |
1164 | 685 |
"generic method, subclasses usually redefine this" |
818 | 686 |
|
1223 | 687 |
"/ the first 2-bytes (a short) is the domainCode |
688 |
self replaceBytesFrom:1+2 to:addressBytes size+2 with:addressBytes startingAt:1 |
|
689 |
||
690 |
" |
|
691 |
IPSocketAddress hostAddress:#[193 141 12 193] port:80 |
|
692 |
" |
|
818 | 693 |
! |
694 |
||
1223 | 695 |
hostAddress:addressBytes port:portNr |
696 |
self hostAddress:addressBytes. |
|
818 | 697 |
self port:portNr |
698 |
||
699 |
" |
|
700 |
IPSocketAddress hostAddress:#[193 141 12 193] port:10 |
|
701 |
" |
|
1223 | 702 |
! |
818 | 703 |
|
1934 | 704 |
hostAddressString |
705 |
^ String streamContents:[:s | self printAddressOn:s ]. |
|
706 |
! |
|
707 |
||
1223 | 708 |
port |
709 |
self subclassResponsibility |
|
710 |
! |
|
711 |
||
712 |
port:portNr |
|
713 |
self subclassResponsibility |
|
818 | 714 |
! ! |
715 |
||
3515 | 716 |
!SocketAddress methodsFor:'comparing'! |
717 |
||
3521 | 718 |
sameHostAddress:aSocketAddress |
719 |
"answer true, if aSocketAddres has the same hostaddress as myself" |
|
720 |
||
721 |
^ self class = aSocketAddress class |
|
722 |
and:[self hostAddress = aSocketAddress hostAddress] |
|
3515 | 723 |
|
3521 | 724 |
" |
725 |
(IPSocketAddress hostAddress:#[193 141 12 193] port:80) |
|
726 |
sameHostAddress: |
|
727 |
(IPSocketAddress hostAddress:#[193 141 12 193] port:81) |
|
728 |
" |
|
3515 | 729 |
! ! |
730 |
||
3523 | 731 |
!SocketAddress methodsFor:'converting'! |
732 |
||
733 |
asIPv4SocketAddressIfPossible |
|
734 |
^ self |
|
735 |
! ! |
|
736 |
||
2429 | 737 |
!SocketAddress methodsFor:'hashing'! |
738 |
||
739 |
hash |
|
740 |
"generate a SmallInteger hash for the socket address - use all the bytes" |
|
741 |
||
742 |
^ self computeXorHashFrom:1 to:0 |
|
743 |
! ! |
|
744 |
||
1164 | 745 |
!SocketAddress methodsFor:'printing & storing'! |
746 |
||
2493
991ac8697cfb
Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2460
diff
changeset
|
747 |
displayOn:aGCOrStream |
1228
b766b9873ba6
refactored & dead code eliminated
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
748 |
"redefine from Collection" |
1164 | 749 |
|
2493
991ac8697cfb
Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2460
diff
changeset
|
750 |
"/ what a kludge - Dolphin and Squeak mean: printOn: a stream; |
4353 | 751 |
"/ old ST80 means: draw-yourself on a GC. |
752 |
(aGCOrStream isStream) ifFalse:[ |
|
753 |
^ super displayOn:aGCOrStream |
|
2493
991ac8697cfb
Implement display with #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2460
diff
changeset
|
754 |
]. |
1164 | 755 |
|
4353 | 756 |
self printOn:aGCOrStream. |
757 |
||
758 |
"Modified: / 22-02-2017 / 16:59:49 / cg" |
|
1333 | 759 |
! |
760 |
||
761 |
printAddressOn:arg |
|
762 |
"raise an error: must be redefined in concrete subclass(es)" |
|
763 |
||
764 |
^ self subclassResponsibility |
|
765 |
! |
|
766 |
||
767 |
printOn:aStream |
|
768 |
"append a user printed representation of the receiver to aStream. |
|
769 |
The format is suitable for a human - not meant to be read back." |
|
770 |
||
771 |
self printOn:aStream withPort:true |
|
772 |
! |
|
773 |
||
774 |
printOn:aStream withPort:withPort |
|
775 |
"append a user printed representation of the receiver to aStream. |
|
776 |
The format is suitable for a human - not meant to be read back." |
|
777 |
||
778 |
self printAddressOn:aStream. |
|
779 |
withPort ifTrue:[ |
|
780 |
self printPortOn:aStream. |
|
781 |
]. |
|
782 |
! |
|
783 |
||
784 |
printPortOn:aStream |
|
785 |
|port| |
|
786 |
||
787 |
(port := self port) ~~ 0 ifTrue:[ |
|
788 |
aStream nextPut:$:. |
|
789 |
port printOn:aStream. |
|
790 |
] |
|
1164 | 791 |
! ! |
792 |
||
793 |
!SocketAddress methodsFor:'private'! |
|
794 |
||
795 |
fromBytes:aByteArray |
|
796 |
"Copy the internal representation of a SocketAddress to myself |
|
797 |
||
798 |
This is an internal interface!!" |
|
799 |
||
1225 | 800 |
self replaceBytesFrom:1 to:(self size) with:aByteArray startingAt:1. |
801 |
||
802 |
||
1164 | 803 |
! ! |
804 |
||
100 | 805 |
!SocketAddress methodsFor:'queries'! |
806 |
||
488 | 807 |
address |
808 |
^ self subclassResponsibility |
|
809 |
! |
|
810 |
||
3055
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
811 |
domain |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
812 |
"anwer the domain symbol used to creat a socket" |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
813 |
|
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
814 |
^ self class domain |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
815 |
! |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
816 |
|
111 | 817 |
hostName |
1164 | 818 |
^ (self class getNameInfo:self wantHostName:true |
819 |
wantServiceName:false datagram:false flags:0) first |
|
111 | 820 |
|
1164 | 821 |
" |
1259
0a557e59ea4a
instance creation refactored
Claus Gittinger <cg@exept.de>
parents:
1232
diff
changeset
|
822 |
(IPSocketAddress hostAddress:#[127 0 0 1]) hostName |
0a557e59ea4a
instance creation refactored
Claus Gittinger <cg@exept.de>
parents:
1232
diff
changeset
|
823 |
(IPSocketAddress hostName:'localhost') address |
0a557e59ea4a
instance creation refactored
Claus Gittinger <cg@exept.de>
parents:
1232
diff
changeset
|
824 |
(IPSocketAddress hostName:'www.google.com') address |
0a557e59ea4a
instance creation refactored
Claus Gittinger <cg@exept.de>
parents:
1232
diff
changeset
|
825 |
|
0a557e59ea4a
instance creation refactored
Claus Gittinger <cg@exept.de>
parents:
1232
diff
changeset
|
826 |
(IPSocketAddress hostAddress:#[127 0 0 1] port:7) hostName |
3525 | 827 |
(IPSocketAddress hostAddress:#[172 23 1 1] port:10) hostName |
828 |
(IPSocketAddress hostAddress:#[172 24 1 244]) hostName |
|
829 |
(IPv6SocketAddress hostAddress: #[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]) hostName |
|
830 |
(IPv6SocketAddress hostAddress: #[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2]) hostName |
|
3526 | 831 |
(IPv6SocketAddress hostAddress: #[0 0 0 0 0 0 0 0 0 0 255 255 127 0 0 1]) hostName |
832 |
(IPv6SocketAddress hostAddress: #[0 0 0 0 0 0 0 0 0 0 255 255 172 23 1 1]) hostName |
|
1164 | 833 |
" |
111 | 834 |
! |
835 |
||
1366
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
836 |
hostNameOrAddressString |
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
837 |
"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
|
838 |
of the address" |
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
839 |
|
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
840 |
^ [ |
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
841 |
self hostName. |
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
842 |
] on:NameLookupError do:[:ex| |stream| |
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
843 |
stream := '' writeStream. |
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
844 |
self printAddressOn:stream. |
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
845 |
stream contents. |
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
846 |
]. |
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
847 |
|
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
848 |
" |
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
849 |
(IPSocketAddress hostName:'localhost') hostNameOrAddressString |
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
850 |
(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
|
851 |
" |
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
852 |
! |
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
853 |
|
100 | 854 |
portOrName |
210 | 855 |
^ self subclassResponsibility |
1164 | 856 |
! |
857 |
||
858 |
serviceName |
|
859 |
^ (self class getNameInfo:self wantHostName:false |
|
860 |
wantServiceName:true datagram:false flags:0) second |
|
861 |
||
862 |
" |
|
863 |
(IPSocketAddress hostAddress:#[127 0 0 1] port:7) serviceName |
|
864 |
(IPSocketAddress hostAddress:#[193 141 12 193] port:10) serviceName |
|
865 |
" |
|
100 | 866 |
! ! |
867 |
||
1366
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
868 |
!SocketAddress methodsFor:'testing'! |
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
869 |
|
3051 | 870 |
isIPSocketAddress |
871 |
^ false |
|
872 |
! |
|
873 |
||
874 |
isIPv4SocketAddress |
|
875 |
^ false |
|
876 |
! |
|
877 |
||
878 |
isIPv6SocketAddress |
|
879 |
^ false |
|
880 |
! |
|
881 |
||
1366
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
882 |
isLocal |
3983 | 883 |
"answer true, if this address addresses a peer on the same host" |
1366
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
884 |
|
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
885 |
^ self subclassResponsibility |
3047 | 886 |
! |
887 |
||
888 |
isMyAddress |
|
889 |
"answer true, if the address refers to my own host. |
|
890 |
Subclasses may redefine this to check the local configuration, too." |
|
891 |
||
892 |
^ self isLocal |
|
3055
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
893 |
! |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
894 |
|
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
895 |
isSocketAddress |
df35ff76de4a
changes #domainSymbol to #domain fpr comaptibility with Socket
Stefan Vogel <sv@exept.de>
parents:
3051
diff
changeset
|
896 |
^ true |
1366
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
897 |
! ! |
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1333
diff
changeset
|
898 |
|
488 | 899 |
!SocketAddress class methodsFor:'documentation'! |
900 |
||
901 |
version |
|
3583 | 902 |
^ '$Header$' |
2338 | 903 |
! |
904 |
||
905 |
version_CVS |
|
3583 | 906 |
^ '$Header$' |
488 | 907 |
! ! |
3047 | 908 |