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