checkin from browser
authorClaus Gittinger <cg@exept.de>
Tue, 21 Sep 1999 02:27:27 +0200
changeset 818 2f8331ad12d4
parent 817 eda0065cbd47
child 819 4cc15700d123
checkin from browser
AppletalkSocketAddress.st
IPSocketAddress.st
IPv6SocketAddress.st
SocketAddress.st
UDSocketAddress.st
--- a/AppletalkSocketAddress.st	Tue Sep 21 01:58:18 1999 +0200
+++ b/AppletalkSocketAddress.st	Tue Sep 21 02:27:27 1999 +0200
@@ -11,8 +11,8 @@
 "
 
 
-SocketAddress subclass:#AppletalkSocketAddress
-	instanceVariableNames:'port address'
+SocketAddress variableByteSubclass:#AppletalkSocketAddress
+	instanceVariableNames:'port'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'OS-Sockets'
@@ -52,6 +52,12 @@
 "
 ! !
 
+!AppletalkSocketAddress class methodsFor:'instance creation'!
+
+new
+    ^ self new:3
+! !
+
 !AppletalkSocketAddress class methodsFor:'queries'!
 
 hostAddressByName: hostName
@@ -74,36 +80,45 @@
 
 ! !
 
-!AppletalkSocketAddress methodsFor:'queries'!
-
-hostAddress:anAddress
-    address := anAddress
-
-!
-
-hostName
-    ^ Socket hostWithAppletalkAddress:address
-
-
-!
+!AppletalkSocketAddress methodsFor:'accessing'!
 
 net
-    ^ address wordAt:1 MSB:true
+    ^ ((self at:1) bitShift:8) bitOr:(self at:2)
 
 
 !
 
 net:aNodeAddress
-    address isNil ifTrue:[
-        address := ByteArray new:3
-    ].
-    address at:3 put:aNodeAddress
+    self at:1 put:((aNodeAddress bitShift:-1) bitAnd:16rFF).
+    self at:2 put:(aNodeAddress bitAnd:16rFF).
+
+    "
+     self new net:16r1234
+    "
+!
+
+net:netNr node:nodeNr port:portNr
+    self 
+        net:netNr;
+        node:nodeNr;
+        port:portNr
+
+    "
+     AppletalkSocketAddress new net:1234 node:10 port:20
+    "
+    "
+     AppletalkSocketAddress hostAddress:#[1 2 3] port:10
+    "
+!
+
+node
+    ^ self at:3
 
 
 !
 
-node
-    ^ address at:3
+node:aNodeNr
+    self at:3 put:aNodeNr
 
 
 !
@@ -113,6 +128,36 @@
 
 !
 
+port:aPortNr
+    port := aPortNr
+
+! !
+
+!AppletalkSocketAddress methodsFor:'printing & storing'!
+
+printOn:aStream
+    "append a user printed representation of the receiver to aStream.
+     The format is suitable for a human - not meant to be read back."
+
+    self net printOn:aStream.
+    aStream nextPut:$:.
+    self node printOn:aStream.
+    port notNil ifTrue:[
+        aStream nextPut:$:.
+        port printOn:aStream.
+    ].
+
+
+! !
+
+!AppletalkSocketAddress methodsFor:'queries'!
+
+hostName
+    ^ Socket hostWithAppletalkAddress:self
+
+
+!
+
 portOrName
     ^ port
 
@@ -121,5 +166,5 @@
 !AppletalkSocketAddress class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/AppletalkSocketAddress.st,v 1.1 1999-09-20 23:53:08 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/AppletalkSocketAddress.st,v 1.2 1999-09-21 00:27:14 cg Exp $'
 ! !
--- a/IPSocketAddress.st	Tue Sep 21 01:58:18 1999 +0200
+++ b/IPSocketAddress.st	Tue Sep 21 02:27:27 1999 +0200
@@ -10,8 +10,8 @@
  hereby transferred.
 "
 
-SocketAddress subclass:#IPSocketAddress
-	instanceVariableNames:'port address'
+SocketAddress variableByteSubclass:#IPSocketAddress
+	instanceVariableNames:'port'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'OS-Sockets'
@@ -61,6 +61,14 @@
 "
 ! !
 
+!IPSocketAddress class methodsFor:'instance creation'!
+
+new
+    ^ self new:4
+
+
+! !
+
 !IPSocketAddress class methodsFor:'queries'!
 
 hostAddressByName: hostName
@@ -94,18 +102,27 @@
 
 !IPSocketAddress methodsFor:'accessing'!
 
-hostAddress:addr port:portNr
-    address := addr.
-    port := portNr
+hostAddress
+    ^ (ByteArray new:4) replaceFrom:1 to:4 with:self startingAt:1
+
 !
 
 hostName:name port:portNr
-    address := Socket ipAddressOfHost:name.
-    port := portNr
+    self 
+        hostAddress:(Socket ipAddressOfHost:name)
+        port:portNr
 
     "
      IPSocketAddress hostName:'exept' port:10
     "
+!
+
+port
+    ^ port
+!
+
+port:aPortNr
+    port := aPortNr
 ! !
 
 !IPSocketAddress methodsFor:'printing & storing'!
@@ -114,7 +131,12 @@
     "append a user printed representation of the receiver to aStream.
      The format is suitable for a human - not meant to be read back."
 
-    address do:[:el | el printOn:aStream] inBetweenDo:[ aStream nextPut:$.].
+    1 to:4 do:[:i | 
+        (i between:2 and:4) ifTrue:[
+            aStream nextPut:$.
+        ].
+        (self at:i) printOn:aStream
+    ].
     port notNil ifTrue:[
         aStream nextPut:$:.
         port printOn:aStream.
@@ -124,29 +146,19 @@
 !IPSocketAddress methodsFor:'queries'!
 
 address
-    ^ address
-!
-
-hostAddress
-    ^ address 
-!
-
-hostAddress:anAddress
-    address := anAddress
-
-    "Created: 28.3.1997 / 18:15:04 / cg"
+    ^ self hostAddress
 !
 
 hostName
-    ^ Socket hostWithIpAddress:address
+    ^ Socket hostWithIpAddress:self
+
+    "
+     (IPSocketAddress hostAddress:#[193 141 12 193] port:10) hostName
+    "
 
     "Created: 2.11.1995 / 11:17:28 / cg"
 !
 
-port
-    ^ port
-!
-
 portOrName
     ^ port
 ! !
@@ -154,5 +166,5 @@
 !IPSocketAddress class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/IPSocketAddress.st,v 1.9 1999-09-20 23:52:58 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/IPSocketAddress.st,v 1.10 1999-09-21 00:27:23 cg Exp $'
 ! !
--- a/IPv6SocketAddress.st	Tue Sep 21 01:58:18 1999 +0200
+++ b/IPv6SocketAddress.st	Tue Sep 21 02:27:27 1999 +0200
@@ -12,7 +12,7 @@
 
 
 
-IPSocketAddress subclass:#IPv6SocketAddress
+IPSocketAddress variableByteSubclass:#IPv6SocketAddress
 	instanceVariableNames:''
 	classVariableNames:''
 	poolDictionaries:''
@@ -55,6 +55,21 @@
 
 ! !
 
+!IPv6SocketAddress class methodsFor:'instance creation'!
+
+new
+    ^ self new:16
+
+
+! !
+
+!IPv6SocketAddress methodsFor:'accessing'!
+
+port
+    ^ port
+
+! !
+
 !IPv6SocketAddress methodsFor:'queries'!
 
 hostName
@@ -63,11 +78,6 @@
 
 !
 
-port
-    ^ port
-
-!
-
 portOrName
     ^ port
 
@@ -76,5 +86,5 @@
 !IPv6SocketAddress class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/IPv6SocketAddress.st,v 1.1 1999-09-20 23:52:56 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/IPv6SocketAddress.st,v 1.2 1999-09-21 00:27:20 cg Exp $'
 ! !
--- a/SocketAddress.st	Tue Sep 21 01:58:18 1999 +0200
+++ b/SocketAddress.st	Tue Sep 21 02:27:27 1999 +0200
@@ -10,7 +10,7 @@
  hereby transferred.
 "
 
-Object subclass:#SocketAddress
+UninterpretedBytes variableByteSubclass:#SocketAddress
 	instanceVariableNames:''
 	classVariableNames:''
 	poolDictionaries:''
@@ -64,11 +64,16 @@
 !SocketAddress class methodsFor:'instance creation'!
 
 hostAddress:addr port:portNr
-    ^ self basicNew hostAddress:addr port:portNr
+    ^ self new hostAddress:addr port:portNr
 !
 
 hostName:name port:portNr
-    ^ self basicNew hostName:name port:portNr
+    ^ self new hostName:name port:portNr
+!
+
+new
+    ^ self subclassResponsibility
+
 ! !
 
 !SocketAddress class methodsFor:'queries'!
@@ -138,6 +143,24 @@
 
 ! !
 
+!SocketAddress methodsFor:'accessing'!
+
+hostAddress:anAddress
+    self replaceBytesFrom:1 to:anAddress size with:anAddress startingAt:1
+
+
+!
+
+hostAddress:addr port:portNr
+    self hostAddress:addr.
+    self port:portNr
+
+    "
+     IPSocketAddress hostAddress:#[193 141 12 193] port:10
+    "
+
+! !
+
 !SocketAddress methodsFor:'queries'!
 
 address
@@ -157,5 +180,5 @@
 !SocketAddress class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/SocketAddress.st,v 1.8 1999-09-20 23:53:02 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/SocketAddress.st,v 1.9 1999-09-21 00:27:27 cg Exp $'
 ! !
--- a/UDSocketAddress.st	Tue Sep 21 01:58:18 1999 +0200
+++ b/UDSocketAddress.st	Tue Sep 21 02:27:27 1999 +0200
@@ -10,7 +10,7 @@
  hereby transferred.
 "
 
-SocketAddress subclass:#UDSocketAddress
+SocketAddress variableByteSubclass:#UDSocketAddress
 	instanceVariableNames:'name'
 	classVariableNames:''
 	poolDictionaries:''
@@ -93,5 +93,5 @@
 !UDSocketAddress class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/UDSocketAddress.st,v 1.6 1999-09-20 23:53:10 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/UDSocketAddress.st,v 1.7 1999-09-21 00:27:17 cg Exp $'
 ! !