100
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
770
|
3 |
All Rights Reserved
|
100
|
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 |
|
|
13 |
SocketAddress subclass:#IPSocketAddress
|
488
|
14 |
instanceVariableNames:'port address'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'ST80-Compatibility'
|
100
|
18 |
!
|
|
19 |
|
|
20 |
!IPSocketAddress class methodsFor:'documentation'!
|
|
21 |
|
|
22 |
copyright
|
|
23 |
"
|
|
24 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
770
|
25 |
All Rights Reserved
|
100
|
26 |
|
|
27 |
This software is furnished under a license and may be used
|
|
28 |
only in accordance with the terms of that license and with the
|
|
29 |
inclusion of the above copyright notice. This software may not
|
|
30 |
be provided or otherwise made available to, or used by, any
|
|
31 |
other person. No title to or ownership of the software is
|
|
32 |
hereby transferred.
|
|
33 |
"
|
|
34 |
!
|
|
35 |
|
|
36 |
documentation
|
|
37 |
"
|
111
|
38 |
Instances of IPSocketAddress represent tcp/ip-domain socket addresses.
|
|
39 |
These consist of an ip address (4 bytes) and a port number.
|
|
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 |
|
488
|
64 |
!IPSocketAddress class methodsFor:'instance creation'!
|
|
65 |
|
|
66 |
hostAddress:addr port:portNr
|
|
67 |
^ self basicNew
|
770
|
68 |
hostAddress:addr port:portNr
|
488
|
69 |
! !
|
|
70 |
|
100
|
71 |
!IPSocketAddress class methodsFor:'queries'!
|
|
72 |
|
|
73 |
hostAddressByName: hostName
|
|
74 |
^ Socket ipAddressOfHost:hostName
|
|
75 |
|
|
76 |
"
|
|
77 |
IPSocketAddress hostAddressByName:'clam'
|
|
78 |
IPSocketAddress hostAddressByName:'foobar'
|
|
79 |
"
|
|
80 |
!
|
|
81 |
|
|
82 |
hostNameByAddress: anAddress
|
|
83 |
^ Socket hostWithIpAddress:anAddress
|
|
84 |
|
|
85 |
"
|
|
86 |
|addr|
|
|
87 |
|
|
88 |
addr := IPSocketAddress hostAddressByName:'porty'.
|
|
89 |
IPSocketAddress hostNameByAddress:addr
|
|
90 |
"
|
|
91 |
! !
|
|
92 |
|
|
93 |
!IPSocketAddress methodsFor:'accessing'!
|
|
94 |
|
|
95 |
hostAddress:addr port:portNr
|
|
96 |
address := addr.
|
|
97 |
port := portNr
|
|
98 |
! !
|
|
99 |
|
770
|
100 |
!IPSocketAddress methodsFor:'printing & storing'!
|
|
101 |
|
|
102 |
printOn:aStream
|
|
103 |
"append a user printed representation of the receiver to aStream.
|
|
104 |
The format is suitable for a human - not meant to be read back."
|
|
105 |
|
|
106 |
address printOn:aStream.
|
|
107 |
port notNil ifTrue:[
|
|
108 |
aStream nextPut:$:.
|
|
109 |
port printOn:aStream.
|
|
110 |
].
|
|
111 |
! !
|
|
112 |
|
100
|
113 |
!IPSocketAddress methodsFor:'queries'!
|
|
114 |
|
488
|
115 |
address
|
|
116 |
^ address
|
|
117 |
!
|
|
118 |
|
|
119 |
hostAddress
|
|
120 |
^ address
|
|
121 |
!
|
|
122 |
|
514
|
123 |
hostAddress:anAddress
|
|
124 |
address := anAddress
|
|
125 |
|
|
126 |
"Created: 28.3.1997 / 18:15:04 / cg"
|
|
127 |
!
|
|
128 |
|
111
|
129 |
hostName
|
|
130 |
^ Socket hostWithIpAddress:address
|
|
131 |
|
|
132 |
"Created: 2.11.1995 / 11:17:28 / cg"
|
|
133 |
!
|
|
134 |
|
100
|
135 |
port
|
|
136 |
^ port
|
|
137 |
!
|
|
138 |
|
|
139 |
portOrName
|
|
140 |
^ port
|
488
|
141 |
! !
|
|
142 |
|
|
143 |
!IPSocketAddress class methodsFor:'documentation'!
|
100
|
144 |
|
488
|
145 |
version
|
770
|
146 |
^ '$Header: /cvs/stx/stx/libbasic2/IPSocketAddress.st,v 1.6 1999-07-15 19:46:26 cg Exp $'
|
100
|
147 |
! !
|