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