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