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