class: SocketAddress
authorClaus Gittinger <cg@exept.de>
Sat, 24 Jan 2015 00:02:47 +0100
changeset 3466 d54258560694
parent 3465 c15c6d70877f
child 3467 24d35ef42e17
class: SocketAddress changed: #domainCode #domainCode: fix for OSX
SocketAddress.st
--- a/SocketAddress.st	Mon Jan 12 14:59:00 2015 +0100
+++ b/SocketAddress.st	Sat Jan 24 00:02:47 2015 +0100
@@ -11,6 +11,8 @@
 "
 "{ Package: 'stx:libbasic2' }"
 
+"{ NameSpace: Smalltalk }"
+
 UninterpretedBytes variableByteSubclass:#SocketAddress
 	instanceVariableNames:''
 	classVariableNames:'DomainToClassMapping Verbose LastName LastPort LastType LastAddr
@@ -617,11 +619,29 @@
 !SocketAddress methodsFor:'accessing'!
 
 domainCode
+    "this opaquely returns the first two bytes as a short integer;
+     Notice: some systems store the domainCode in those 2 bytes,
+     whereas others (IOS) store the size of the addr-struct in byte 1,
+     and the actual domain code in byte 2"
+
+    OperatingSystem isOSXlike ifTrue:[
+        ^ self at:2
+    ].
     ^ self unsignedShortAt:1
 !
 
 domainCode:anInteger
-    self unsignedShortAt:1 put:anInteger
+    "this opaquely sets the first two bytes as a short integer;
+     Notice: some systems store the domainCode in those 2 bytes,
+     whereas others (IOS) store the size of the addr-struct in byte 1,
+     and the actual domain code in byte 2"
+
+    OperatingSystem isOSXlike ifTrue:[
+        self at:1 put:self size.
+        self at:2 put:anInteger.
+    ] ifFalse:[ 
+        self unsignedShortAt:1 put:anInteger
+    ].
 !
 
 hostAddress:addressBytes
@@ -829,10 +849,10 @@
 !SocketAddress class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/SocketAddress.st,v 1.46 2014-07-10 12:23:59 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/SocketAddress.st,v 1.47 2015-01-23 23:02:47 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic2/SocketAddress.st,v 1.46 2014-07-10 12:23:59 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/SocketAddress.st,v 1.47 2015-01-23 23:02:47 cg Exp $'
 ! !