author | Claus Gittinger <cg@exept.de> |
Thu, 08 Nov 2007 17:34:59 +0100 | |
changeset 1913 | 4c2622e92a91 |
parent 1908 | 7d5c6c7d805f |
child 1936 | d9cc04bdd113 |
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 |
SocketAddress variableByteSubclass:#UDSocketAddress |
1164 | 15 |
instanceVariableNames:'' |
488 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
816 | 18 |
category:'OS-Sockets' |
100 | 19 |
! |
20 |
||
21 |
!UDSocketAddress class methodsFor:'documentation'! |
|
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
111 | 39 |
Instances of UDSocketAddress represent unix-domain socket names. |
40 |
||
100 | 41 |
ST-80 compatibility class. |
42 |
This may be required when existing code has to be ported to ST/X; |
|
43 |
however, it may not be complete and more protocol may be added in the future. |
|
44 |
The code here was created when public domain code (Manchester) had to |
|
45 |
be ported to ST/X and missing classes/methods were encountered, and code added |
|
46 |
by reasoning 'what the original class could probably do there'. |
|
47 |
||
48 |
This is an additional goody class; therefore: |
|
49 |
||
50 |
THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTOR ``AS IS'' AND |
|
51 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
52 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
53 |
ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTOR BE LIABLE |
|
54 |
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
55 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
56 |
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
57 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
58 |
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
59 |
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
60 |
SUCH DAMAGE. |
|
61 |
" |
|
62 |
! ! |
|
63 |
||
64 |
!UDSocketAddress class methodsFor:'instance creation'! |
|
65 |
||
1908
7d5c6c7d805f
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1366
diff
changeset
|
66 |
allForHostName:hostName serviceName:portNrOrName type:socketTypeSymbol |
7d5c6c7d805f
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1366
diff
changeset
|
67 |
(hostName notNil and:[hostName ~= 'localhost']) ifTrue:[ |
7d5c6c7d805f
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1366
diff
changeset
|
68 |
self error:'Only local connections possible with UD sockets'. |
7d5c6c7d805f
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1366
diff
changeset
|
69 |
^ nil. |
7d5c6c7d805f
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1366
diff
changeset
|
70 |
]. |
7d5c6c7d805f
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1366
diff
changeset
|
71 |
|
7d5c6c7d805f
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1366
diff
changeset
|
72 |
Array with:(self name:portNrOrName). |
7d5c6c7d805f
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1366
diff
changeset
|
73 |
! |
7d5c6c7d805f
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1366
diff
changeset
|
74 |
|
1319
4b9a0784a799
Protocol compatibility: #anyHost, #port
Stefan Vogel <sv@exept.de>
parents:
1262
diff
changeset
|
75 |
anyHost |
4b9a0784a799
Protocol compatibility: #anyHost, #port
Stefan Vogel <sv@exept.de>
parents:
1262
diff
changeset
|
76 |
"there is nothing like a 'host' for unix domain sockets. |
4b9a0784a799
Protocol compatibility: #anyHost, #port
Stefan Vogel <sv@exept.de>
parents:
1262
diff
changeset
|
77 |
answer an empty address" |
4b9a0784a799
Protocol compatibility: #anyHost, #port
Stefan Vogel <sv@exept.de>
parents:
1262
diff
changeset
|
78 |
|
4b9a0784a799
Protocol compatibility: #anyHost, #port
Stefan Vogel <sv@exept.de>
parents:
1262
diff
changeset
|
79 |
^ self new |
4b9a0784a799
Protocol compatibility: #anyHost, #port
Stefan Vogel <sv@exept.de>
parents:
1262
diff
changeset
|
80 |
! |
4b9a0784a799
Protocol compatibility: #anyHost, #port
Stefan Vogel <sv@exept.de>
parents:
1262
diff
changeset
|
81 |
|
100 | 82 |
name: pathName |
83 |
^ self new name:pathName |
|
84 |
||
85 |
" |
|
86 |
UDSocketAddress name:'/tmp/aUnixDomainSocket' |
|
87 |
" |
|
1259
0a557e59ea4a
instance creation refactored
Claus Gittinger <cg@exept.de>
parents:
1228
diff
changeset
|
88 |
! |
0a557e59ea4a
instance creation refactored
Claus Gittinger <cg@exept.de>
parents:
1228
diff
changeset
|
89 |
|
0a557e59ea4a
instance creation refactored
Claus Gittinger <cg@exept.de>
parents:
1228
diff
changeset
|
90 |
peerName:peerName port:port |
1908
7d5c6c7d805f
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1366
diff
changeset
|
91 |
"use #name:" |
7d5c6c7d805f
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1366
diff
changeset
|
92 |
|
7d5c6c7d805f
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1366
diff
changeset
|
93 |
<resource: #obsolete> |
7d5c6c7d805f
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1366
diff
changeset
|
94 |
self obsoleteMethodWarning:'use name:'. |
1259
0a557e59ea4a
instance creation refactored
Claus Gittinger <cg@exept.de>
parents:
1228
diff
changeset
|
95 |
^ self name:peerName |
100 | 96 |
! ! |
97 |
||
1164 | 98 |
!UDSocketAddress class methodsFor:'queries'! |
99 |
||
100 |
domainSymbol |
|
100 | 101 |
|
1226
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
102 |
^ #'AF_UNIX' |
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
103 |
! |
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
104 |
|
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
105 |
obsoleteDomainSymbol |
1164 | 106 |
^ #unix |
107 |
! |
|
108 |
||
1259
0a557e59ea4a
instance creation refactored
Claus Gittinger <cg@exept.de>
parents:
1228
diff
changeset
|
109 |
peerNameFromPeer:peer |
0a557e59ea4a
instance creation refactored
Claus Gittinger <cg@exept.de>
parents:
1228
diff
changeset
|
110 |
^ 'localhost' |
0a557e59ea4a
instance creation refactored
Claus Gittinger <cg@exept.de>
parents:
1228
diff
changeset
|
111 |
! |
0a557e59ea4a
instance creation refactored
Claus Gittinger <cg@exept.de>
parents:
1228
diff
changeset
|
112 |
|
1226
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
113 |
vwDomainSymbol |
0114bd044aa9
vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
114 |
^ #afUnix |
100 | 115 |
! ! |
116 |
||
1164 | 117 |
!UDSocketAddress methodsFor:'accessing'! |
118 |
||
119 |
name |
|
120 |
^ self stringAt:3 |
|
121 |
! |
|
122 |
||
123 |
name:pathName |
|
1908
7d5c6c7d805f
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1366
diff
changeset
|
124 |
pathName isString ifFalse:[ |
7d5c6c7d805f
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1366
diff
changeset
|
125 |
self error:'Unix domain sockets require a path argument'. |
7d5c6c7d805f
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1366
diff
changeset
|
126 |
]. |
1164 | 127 |
self stringAt:3 put:pathName |
1319
4b9a0784a799
Protocol compatibility: #anyHost, #port
Stefan Vogel <sv@exept.de>
parents:
1262
diff
changeset
|
128 |
! |
4b9a0784a799
Protocol compatibility: #anyHost, #port
Stefan Vogel <sv@exept.de>
parents:
1262
diff
changeset
|
129 |
|
4b9a0784a799
Protocol compatibility: #anyHost, #port
Stefan Vogel <sv@exept.de>
parents:
1262
diff
changeset
|
130 |
port |
4b9a0784a799
Protocol compatibility: #anyHost, #port
Stefan Vogel <sv@exept.de>
parents:
1262
diff
changeset
|
131 |
"ccompatibility with inet sockets" |
4b9a0784a799
Protocol compatibility: #anyHost, #port
Stefan Vogel <sv@exept.de>
parents:
1262
diff
changeset
|
132 |
|
4b9a0784a799
Protocol compatibility: #anyHost, #port
Stefan Vogel <sv@exept.de>
parents:
1262
diff
changeset
|
133 |
^ self name |
1164 | 134 |
! ! |
135 |
||
136 |
!UDSocketAddress methodsFor:'obsolete'! |
|
100 | 137 |
|
488 | 138 |
address |
139 |
^ nil |
|
140 |
! |
|
141 |
||
111 | 142 |
hostName |
1164 | 143 |
^ 'local' |
144 |
! |
|
145 |
||
146 |
hostName:hostOrPathName port:portNrOrName |
|
147 |
self name:hostOrPathName |
|
148 |
! |
|
149 |
||
150 |
port:pathName |
|
151 |
self name:pathName |
|
111 | 152 |
! |
153 |
||
100 | 154 |
portOrName |
1164 | 155 |
^ self name |
156 |
! ! |
|
157 |
||
158 |
!UDSocketAddress methodsFor:'printing & storing'! |
|
159 |
||
160 |
printOn:aStream |
|
161 |
aStream nextPutAll:self class name; |
|
162 |
nextPut:$(; nextPutAll:self name; nextPut:$) |
|
163 |
||
164 |
" |
|
165 |
(self name:'/tmp/abcde') printString |
|
166 |
" |
|
100 | 167 |
! ! |
168 |
||
1366
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1319
diff
changeset
|
169 |
!UDSocketAddress methodsFor:'testing'! |
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1319
diff
changeset
|
170 |
|
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1319
diff
changeset
|
171 |
isLocal |
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1319
diff
changeset
|
172 |
"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:
1319
diff
changeset
|
173 |
|
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1319
diff
changeset
|
174 |
^ true |
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1319
diff
changeset
|
175 |
! ! |
e01d0f6c102a
New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents:
1319
diff
changeset
|
176 |
|
488 | 177 |
!UDSocketAddress class methodsFor:'documentation'! |
178 |
||
179 |
version |
|
1908
7d5c6c7d805f
Methods to get all addresses for a given hostname (multihomed hosts)
Stefan Vogel <sv@exept.de>
parents:
1366
diff
changeset
|
180 |
^ '$Header: /cvs/stx/stx/libbasic2/UDSocketAddress.st,v 1.15 2007-11-08 14:03:14 stefan Exp $' |
488 | 181 |
! ! |