Merge jv
authorMerge Script
Wed, 30 Sep 2015 07:05:19 +0200
branchjv
changeset 3619 ae55ba1cd11e
parent 3613 71819b26b1bd (current diff)
parent 3618 6a62104daa5f (diff)
child 3623 8d9865be083a
Merge
Socket.st
--- a/.hgtags	Wed Sep 23 06:43:37 2015 +0200
+++ b/.hgtags	Wed Sep 30 07:05:19 2015 +0200
@@ -1,45 +1,47 @@
 01c8098f912ca68e0808e916d4c479b44e0c5918 expecco_1_6_0
 01c8098f912ca68e0808e916d4c479b44e0c5918 expecco_1_6_0rc5
 0465056de290e2bcbbd0e03d6a98cc207cd89833 expecco_1_0_3
+04b2ef9b1ef84c5d046b40593355aa09acf48002 expecco_2_4_0
+04b2ef9b1ef84c5d046b40593355aa09acf48002 expecco_2_4_1
 051b5bef3be7cca43ae6fc8f0cafa827665a4e26 stx_6_2_2
+1465b5fed73effab35e7ed0fb99261b3783dd752 expeccoALM_1_9_0_1
+2ae8f1b57bc12adb6816eb61e797dc3634d064cd expecco_2_5_1
 2dc6e31f014214093e237c5a450818ecadc0a471 rel5_4_6
-2df6c954138e6169b9d92e05d411623df45c5786 expeccoALM_1_9_0_1
-302e72416eb5228ec49a55eb237c6b125d9fa6d4 expecco_2_6_1
+2e9ebced59e6e0395bd50c6defe1079c334d9294 stable
 35bc2d58019dadd6fac7745e583f5f684da29935 expeccoNET_1_6_0_0
+366305432727fee248588749e5c96d726c191c8b expecco_2_7_1
 38fd2b4e49ec5c833c79e69d1ef79a860c656922 expecco_2_2_0
 419dafc801d6396a892c7f1f8a5c3ea2034715ba expecco_1_9_1_iX
 4246989bef13777a6283e156d3f8fc423de74239 rel5_1_4
-4467a141f5eb8b60a6003be75867e32309caacff expecco_2_7_1
-45ee5437c35b630db25bb5c16e4c24c6daf381be expeccoNET_1_8_0_0
 4657f99ed99a88d502586245ae30f243304a9091 rel5_1_3
 4657f99ed99a88d502586245ae30f243304a9091 stx_513
 47159f55bf04bc0220af2aa547abc8dc99903325 rel3_6_1
-48b98b6c1822c422a85516b86e5d207d13e8c748 expecco_2_6_0
-48b98b6c1822c422a85516b86e5d207d13e8c748 expecco_2_6_0_45_windows_final
-48b98b6c1822c422a85516b86e5d207d13e8c748 expecco_2_6_0_49_windows_final
 4d97e4191d041aec0d8df06b0f53c8bdefc002b2 stable_expecco_sel
 4e007cdea6bebbe0aedee6147d58ea2ac6fadd04 expecco_1_5_0
 4f5046f1b0d3b8f6ca53e79b1415a65e0cc821f6 rel3-1-2
-52011218563384c8221603e07d6f975165f28cbc expecco_2_6_2
-53e5df54ecda5a5f0f9cc8dbdd83e667ed6af59e expecco_2_5_1
 554dbbd8cfce13dcfb446c60a7119ca322dd7478 expecco_1_7_0b1
 554dbbd8cfce13dcfb446c60a7119ca322dd7478 expecco_1_7_0b2
 5625df4b611905566a1e01ad0afd700098316d92 expecco_1_8_0rc1
 565ea430832287294b3bcf826e50da1e9eb6e709 rel3_4_1_1
 565ea430832287294b3bcf826e50da1e9eb6e709 rel3_4_1_2
-5c5befefa92fc9be3f90cc5d9e9d36f6d0d61d30 expecco_2_6_0rc1
+6033e5d1226b2e5cf02ac8781f0b5f64d65e0b13 expecco_2_6_0rc1
 632c6a544f8467c0999e48607087ea3a7c6391f6 expeccoNET_1_7_0_0
 635929d2fe7249107b9d6fef63cddc516f040429 expecco_1_7_0rc1
-650cb6bee22d51dddb59f7259423fd476c549e38 expecco_2_5_0
 67f0663627362aa04c5385b8e752071f92657fe3 expeccoNET_1_5_1rc1
 69491b0bdf9d2710f46bd7ac0c54b5ea6d0c5d40 rel3_4_3_1
 6d4adf17cfd620293b7e59901560254dd493ea69 expeccoNET_1_6_8_0
+71647b626b10406e555a2603f2cba2e84d2765c2 expecco_2_6_0
+71647b626b10406e555a2603f2cba2e84d2765c2 expecco_2_6_0_45_windows_final
+71647b626b10406e555a2603f2cba2e84d2765c2 expecco_2_6_0_49_windows_final
+7c0313875ccb013fc3b286d59e101e7153f9fdf3 expecco_2_7_0
+7c0313875ccb013fc3b286d59e101e7153f9fdf3 expecco_2_7_0_49
+7c0313875ccb013fc3b286d59e101e7153f9fdf3 expecco_2_7_5
+7c0313875ccb013fc3b286d59e101e7153f9fdf3 expecco_2_7_5a
 86122f38fc096357a5ab4acb1043548951777670 expecco_1_7_0rc8
-8e5b7dd4d9d62de79afea7f5f65fb4f2977c59b9 expecco_2_4_0
-8e5b7dd4d9d62de79afea7f5f65fb4f2977c59b9 expecco_2_4_1
 8ed4ef8842539fee2628496d77253f2714d3d368 expecco_1_3_4
 91b46f6c8396a633dc55f85cff440fb17af4b8b4 rel2_10_8_5
 9200f060f2dcd01863bd963cc4f9f3cf3c7ffde7 rel2_10_8_6_last_before_vmData_change
+94d67df5c00d6b068ff86cf5c48559aeb71d8b96 expeccoNET_1_8_0_0
 96deeecb60d61ae38747c84d621de475e443c51a rel4_1_3_1
 993d16c301d73aa359d5f9d01b825952f3002241 expeccoNET_1_5_0rc1
 993d16c301d73aa359d5f9d01b825952f3002241 expecco_1_8_2rc1
@@ -48,13 +50,10 @@
 9eecfefd08aa570115237c09710b770cfb802dff expecco_1_7_1rc3
 9eecfefd08aa570115237c09710b770cfb802dff expecco_1_7_1rc4
 a3e5703901c8ea4cad2abdfb0769af7cf31e23a1 rel5_2_8
-a65ead014560eebbe9a03413214cbed0a0970fd2 stable
 a891a2d361b88098ba0e219fe832a3862614f24a expecco_2_0_0
 a891a2d361b88098ba0e219fe832a3862614f24a expecco_2_0_0_0
-b931ae7687078e5a179f0527c486b3dc67dc7a03 expecco_2_7_0
-b931ae7687078e5a179f0527c486b3dc67dc7a03 expecco_2_7_0_49
-b931ae7687078e5a179f0527c486b3dc67dc7a03 expecco_2_7_5
-b931ae7687078e5a179f0527c486b3dc67dc7a03 expecco_2_7_5a
+ad45905bc58bae93ee5af2ef1130ca114daa261e expecco_2_6_2
+b2f07d68255462f98a2273b87c4d40812cb82833 expecco_2_6_1
 c2e0b4299f9e5d89cd89e22ec7f473abc9bed05a rel2_10_8_6_last2
 c31412b263066de0aaf2f1d0f99b142f938d5fd3 rel3_6_4
 c42bd6118058a3f6b8ad911ce60733c571cf42f1 expecco_1_7_2rc1
@@ -62,9 +61,11 @@
 cbb20fd710fa87dc3348b09302816703e24716be release
 cec515dece057a9e4b262c5e4455f8014595962c expecco_1_7_0b3
 d4a984bff73cf8018bf51f187d29fd682903a2bd expecco_2_2_5
+da5f9a98d9e9d7c501f0c415ecbb559961a45d34 expecco_2_5_0
 e05970898f67fd55049e3666ccf037fe0734d3c6 rel5_2_2
 e8f0a47618dcecf0f0eb14eebd44ee5f134f9ec2 rel5_2_1
 ea71dab569531b4ebc581339d095c350f774c839 expecco_2_1_0
 ed0c36ab24b85e742972e9c4b31520f32d364b68 expecco_1_7_0rc5
+f6e8231f090d4fd67eddeba362ca8fcf94edf539 expecco_ALM_1_9_5
 f6f0d919aed24f9f5f3d3d95c9e75ba9f1d751d7 expeccoNET_1_4_0rc1
 f6f0d919aed24f9f5f3d3d95c9e75ba9f1d751d7 expecco_1_7_0rc3
--- a/Socket.st	Wed Sep 23 06:43:37 2015 +0200
+++ b/Socket.st	Wed Sep 30 07:05:19 2015 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 1992 by Claus Gittinger
 	      All Rights Reserved
@@ -136,78 +134,74 @@
 %{
 
 static int
-setupBufferParameters(aDataBuffer, startIndex, p_extPtr, p_offs, p_objSize)
-    OBJ aDataBuffer, startIndex;
-    char **p_extPtr;
-    int *p_offs;
-    int *p_objSize;
+setupBufferParameters(OBJ aDataBuffer, OBJ startIndex, char **p_extPtr, INT *p_offs, size_t *p_objSize)
 {
-	char *extPtr = 0;
-	int sIdx = 0, objSize = 0, offs = 0;
-
-	sIdx = 0;
-	if (__isSmallInteger(startIndex)) {
-	    sIdx = __intVal(startIndex) - 1;
-	}
-
-	if (__isExternalBytesLike(aDataBuffer)) {
-	    OBJ sz;
-
-	    extPtr = (char *)(__externalBytesAddress(aDataBuffer));
-	    sz = __externalBytesSize(aDataBuffer);
-	    if (__isSmallInteger(sz)) {
-		objSize = __intVal(sz);
-	    } else {
-		objSize = 0; /* unknown */
-	    }
-	    offs = sIdx;
-	} else {
-	    OBJ oClass;
-	    int nInstVars, nInstBytes;
-
-	    extPtr = (char *)0;
-	    oClass = __Class(aDataBuffer);
-	    switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
-		case BYTEARRAY:
-		    offs = sIdx;
-		    break;
-		case WORDARRAY:
-		case SWORDARRAY:
-		    offs = sIdx * 2;
-		    break;
-		case LONGARRAY:
-		case SLONGARRAY:
-		    offs = sIdx * 4;
-		    break;
-		case LONGLONGARRAY:
-		case SLONGLONGARRAY:
-		    offs = sIdx * 8;
+        char *extPtr = 0;
+        int sIdx = 0, objSize = 0, offs = 0;
+
+        sIdx = 0;
+        if (__isSmallInteger(startIndex)) {
+            sIdx = __intVal(startIndex) - 1;
+        }
+
+        if (__isExternalBytesLike(aDataBuffer)) {
+            OBJ sz;
+
+            extPtr = (char *)(__externalBytesAddress(aDataBuffer));
+            sz = __externalBytesSize(aDataBuffer);
+            if (__isSmallInteger(sz)) {
+                objSize = __intVal(sz);
+            } else {
+                objSize = 0; /* unknown */
+            }
+            offs = sIdx;
+        } else {
+            OBJ oClass;
+            int nInstVars, nInstBytes;
+
+            extPtr = (char *)0;
+            oClass = __Class(aDataBuffer);
+            switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
+                case BYTEARRAY:
+                    offs = sIdx;
+                    break;
+                case WORDARRAY:
+                case SWORDARRAY:
+                    offs = sIdx * 2;
+                    break;
+                case LONGARRAY:
+                case SLONGARRAY:
+                    offs = sIdx * 4;
+                    break;
+                case LONGLONGARRAY:
+                case SLONGLONGARRAY:
+                    offs = sIdx * 8;
 # ifdef __NEED_LONGLONG_ALIGN
-		    offs += 4;
+                    offs += 4;
 # endif
-		    break;
-		case FLOATARRAY:
-		    offs = sIdx * sizeof(float);
-		    break;
-		case DOUBLEARRAY:
-		    offs = sIdx * sizeof(double);
+                    break;
+                case FLOATARRAY:
+                    offs = sIdx * sizeof(float);
+                    break;
+                case DOUBLEARRAY:
+                    offs = sIdx * sizeof(double);
 # ifdef __NEED_DOUBLE_ALIGN
-		    offs += 4;
+                    offs += 4;
 # endif
-		    break;
-		default:
-		    *p_objSize = -1;
-		    return 0;
-	    }
-	    nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
-	    nInstBytes = OHDR_SIZE + nInstVars * sizeof(OBJ);
-	    offs = offs + nInstBytes;
-	    objSize = __Size(aDataBuffer) - offs;
-	}
-	*p_extPtr = extPtr;
-	*p_objSize = objSize;
-	*p_offs = offs;
-	return 1;
+                    break;
+                default:
+                    *p_objSize = -1;
+                    return 0;
+            }
+            nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
+            nInstBytes = OHDR_SIZE + nInstVars * sizeof(OBJ);
+            offs = offs + nInstBytes;
+            objSize = __Size(aDataBuffer) - offs;
+        }
+        *p_extPtr = extPtr;
+        *p_objSize = objSize;
+        *p_offs = offs;
+        return 1;
 }
 %}
 ! !
@@ -2319,69 +2313,67 @@
     OBJ fp = __INST(handle);
 
     if (fp != nil) {
-	SOCKET sock;
-	INT objSize, offs;
-	INT n;
-	char *extPtr;
-	unsigned char *buffer;
-	unsigned char *allocatedBuffer = NULL;
-	INT flags = 0;
-
-	sock = SOCKET_FROM_FILE_OBJECT(fp);
-
-	if (! setupBufferParameters(aDataBuffer, startIndex, &extPtr, &offs, &objSize)) goto bad;
-	if (__isSmallInteger(nBytes)) {
-	    if (__intVal(nBytes) < objSize) {
-		objSize = __intVal(nBytes);
-	    }
-	}
+        SOCKET sock;
+        INT objSize, offs;
+        INT n;
+        char *extPtr;
+        unsigned char *buffer;
+        unsigned char *allocatedBuffer = NULL;
+        INT flags = 0;
+
+        sock = SOCKET_FROM_FILE_OBJECT(fp);
+
+        if (! setupBufferParameters(aDataBuffer, startIndex, &extPtr, &offs, &objSize)) goto bad;
+        if (__isSmallInteger(nBytes)) {
+            if (__intVal(nBytes) < objSize) {
+                objSize = __intVal(nBytes);
+            }
+        }
 
 # ifdef DO_WRAP_CALLS
-	if (extPtr) {
-	    buffer = extPtr + offs;
-	} else {
-	    allocatedBuffer = buffer = (char *)malloc(objSize);
-	}
-
-	do {
-	    __threadErrno = 0;
-	    n = (INT)STX_WSA_NOINT_CALL4("recv", recv, sock, buffer, objSize, flags);
-	} while ((n < 0) && (__threadErrno == EINTR));
-	if (n < 0) {
-	    errno = __threadErrno;
-	}
-
-	if (allocatedBuffer) {
-	    if (n > 0) {
-		bcopy(allocatedBuffer, (char *)__InstPtr(aDataBuffer) + offs, n);
-	    }
-	    free(allocatedBuffer);
-	}
+        if (extPtr) {
+            buffer = extPtr + offs;
+        } else {
+            allocatedBuffer = buffer = (char *)malloc(objSize);
+        }
+
+        do {
+            __threadErrno = 0;
+            n = (INT)STX_WSA_NOINT_CALL4("recv", recv, sock, buffer, objSize, flags);
+        } while ((n < 0) && (__threadErrno == EINTR));
+        if (n < 0) {
+            errno = __threadErrno;
+        }
+
+        if (allocatedBuffer) {
+            if (n > 0) {
+                bcopy(allocatedBuffer, (char *)__InstPtr(aDataBuffer) + offs, n);
+            }
+            free(allocatedBuffer);
+        }
 # else
-	__BEGIN_INTERRUPTABLE__
-	do {
-	    if (extPtr) {
-		n = recv(sock, extPtr + offs, objSize, flags);
-	    } else {
-		n = recv(sock, (char *)__InstPtr(aDataBuffer) + offs, objSize, flags);
-	    }
-	} while ((n < 0) && (errno == EINTR));
-	__END_INTERRUPTABLE__
+        __BEGIN_INTERRUPTABLE__
+        do {
+            if (extPtr) {
+                n = recv(sock, extPtr + offs, objSize, flags);
+            } else {
+                n = recv(sock, (char *)__InstPtr(aDataBuffer) + offs, objSize, flags);
+            }
+        } while ((n < 0) && (errno == EINTR));
+        __END_INTERRUPTABLE__
 # endif
 
-	if (n < 0) {
-	    error = __INST(lastErrorNumber) = __MKSMALLINT(errno);
-	} else {
-	    RETURN(__MKSMALLINT(n));
-	}
+        if (n < 0) {
+            error = __INST(lastErrorNumber) = __MKSMALLINT(errno);
+        } else {
+            RETURN(__MKSMALLINT(n));
+        }
     }
 #endif
 bad: ;
 %}.
     error notNil ifTrue:[
-	^ ReadError
-	    raiseRequestWith:self
-	    errorString:(' : ' , OperatingSystem errorTextForNumber:error)
+        ^ self readError:error.
     ].
     "
      arrive here if you try to receive into an invalid buffer (i.e. not ByteArray-like)
@@ -2398,10 +2390,14 @@
      On error, the unix error code is left in the lastErrorNumber
      instance variable."
 
-    ^ self receiveFrom:anAddressBuffer buffer:aDataBuffer start:1 for:(aDataBuffer size)
+    ^ self receiveFrom:anAddressBuffer buffer:aDataBuffer start:1 for:(aDataBuffer size) flags:0
 !
 
 receiveFrom:anAddressBuffer buffer:aDataBuffer start:startIndex for:nBytes
+    ^ self receiveFrom:anAddressBuffer buffer:aDataBuffer start:startIndex for:nBytes flags:0
+!
+
+receiveFrom:anAddressBuffer buffer:aDataBuffer start:startIndex for:nBytes flags:flags
     "receive datagramm data
      - put address of originating host into anAddressBuffer, data into aBuffer.
      For backward compatibility, the addressBuffer may be a non-SocketAddress;
@@ -2417,17 +2413,17 @@
 
     domainClass := self class socketAddressClassForDomain:domain.
     domainClass isNil ifTrue:[
-	^ self error:'invalid (unsupported) domain'.
+        ^ self error:'invalid (unsupported) domain'.
     ].
     (anAddressBuffer isKindOf:SocketAddress) ifTrue:[
-	anAddressBuffer class == domainClass ifFalse:[
-	    ^ self error:'addressBuffer class mismatch (domain)'.
-	].
-	addr := anAddressBuffer.
+        anAddressBuffer class == domainClass ifFalse:[
+            ^ self error:'addressBuffer class mismatch (domain)'.
+        ].
+        addr := anAddressBuffer.
     ] ifFalse:[
-	anAddressBuffer notNil ifTrue:[
-	    addr := domainClass new.
-	].
+        anAddressBuffer notNil ifTrue:[
+            addr := domainClass new.
+        ].
     ].
 
 %{
@@ -2435,106 +2431,103 @@
     OBJ fp = __INST(handle);
 
     if (fp != nil) {
-	SOCKET sock;
-	INT objSize;
-	union sockaddr_u sa;
-	unsigned INT alen = 0;
-	INT n, offs;
-	INT flags = 0;
-	char *extPtr;
-	unsigned char *allocatedBuffer = NULL;
-	unsigned char *buffer = NULL;
-
-	sock = SOCKET_FROM_FILE_OBJECT(fp);
-
-	if (! setupBufferParameters(aDataBuffer, startIndex, &extPtr, &offs, &objSize)) goto bad;
-	if (__isSmallInteger(nBytes)) {
-	    if (__intVal(nBytes) < objSize) {
-		objSize = __intVal(nBytes);
-	    }
-	}
+        SOCKET sock;
+        size_t objSize;
+        union sockaddr_u sa;
+        socklen_t alen = 0;
+        INT n, offs;
+        int _flags = __longIntVal(flags);
+        char *extPtr;
+        unsigned char *allocatedBuffer = NULL, *buffer = NULL;
+
+        sock = SOCKET_FROM_FILE_OBJECT(fp);
+
+        if (! setupBufferParameters(aDataBuffer, startIndex, &extPtr, &offs, &objSize)) goto bad;
+        if (__isSmallInteger(nBytes)) {
+            if (__intVal(nBytes) < objSize) {
+                objSize = __intVal(nBytes);
+            }
+        }
 # ifdef DO_WRAP_CALLS
-	if (extPtr) {
-	    buffer = extPtr + offs;
-	} else {
-	    allocatedBuffer = buffer = (char *)malloc(objSize);
-	}
-
-	do {
-	    __threadErrno = 0;
-	    alen = sizeof(sa);
-	    n = (INT)STX_WSA_NOINT_CALL6("recvfrom", recvfrom, sock, buffer, objSize, flags, (struct sockaddr *)&sa, &alen);
-	} while ((n < 0) && (__threadErrno == EINTR));
-	if (n < 0) {
-	    errno = __threadErrno;
-	}
-
-	if (allocatedBuffer) {
-	    if (n > 0) {
-		memcpy((char *)__InstPtr(aDataBuffer) + offs, allocatedBuffer, n);
-	    }
-	    free(allocatedBuffer);
-	}
+        if (extPtr) {
+            buffer = extPtr + offs;
+        } else {
+            allocatedBuffer = buffer = (char *)malloc(objSize);
+        }
+
+        do {
+            __threadErrno = 0;
+            alen = sizeof(sa);
+            n = (INT)STX_WSA_NOINT_CALL6("recvfrom", recvfrom, sock, buffer, objSize, _flags, (struct sockaddr *)&sa, &alen);
+        } while ((n < 0) && (__threadErrno == EINTR));
+        if (n < 0) {
+            errno = __threadErrno;
+        }
+
+        if (allocatedBuffer) {
+            if (n > 0) {
+                memcpy((char *)__InstPtr(aDataBuffer) + offs, allocatedBuffer, n);
+            }
+            free(allocatedBuffer);
+        }
 # else
-	__BEGIN_INTERRUPTABLE__
-	do {
-	    alen = sizeof(sa);
-	    if (extPtr) {
-		n = recvfrom(sock, extPtr + offs, objSize, flags, (struct sockaddr *) &sa, &alen);
-	    } else {
-		n = recvfrom(sock, (char *)__InstPtr(aDataBuffer) + offs, objSize, flags, (struct sockaddr *) &sa, &alen);
-	    }
-	} while ((n < 0) && (errno == EINTR));
-	__END_INTERRUPTABLE__
+        __BEGIN_INTERRUPTABLE__
+        do {
+            alen = sizeof(sa);
+            if (extPtr) {
+                n = recvfrom(sock, extPtr + offs, objSize, _flags, (struct sockaddr *) &sa, &alen);
+            } else {
+                n = recvfrom(sock, (char *)__InstPtr(aDataBuffer) + offs, objSize, _flags, (struct sockaddr *) &sa, &alen);
+            }
+        } while ((n < 0) && (errno == EINTR));
+        __END_INTERRUPTABLE__
 # endif
 
-	if (n >= 0) {
-	    if (__isNonNilObject(addr)) {
-		char *addrPtr;
-		OBJ oClass;
-		int nInstVars, nInstBytes, objSize;
-
-		oClass = __qClass(addr);
-		if (! __isBytes(addr) )
-		    goto bad;
-		nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
-		nInstBytes = OHDR_SIZE + (nInstVars * sizeof(OBJ));
-		objSize = __qSize(addr) - nInstBytes;
-		addrPtr = (char *)__InstPtr(addr) + nInstBytes;
-		if (objSize < alen)
-		    goto bad;
-
-		/*
-		 * extract the datagrams address
-		 */
-		memcpy(addrPtr, (char *)&sa, alen);
-		addrLen = __MKSMALLINT(alen);
-	    }
-	}
-	if (n < 0) {
-	    error = __INST(lastErrorNumber) = __MKSMALLINT(errno);
-	}
-	nReceived = __MKSMALLINT(n);
+        if (n >= 0) {
+            if (__isNonNilObject(addr)) {
+                char *addrPtr;
+                OBJ oClass;
+                int nInstVars, nInstBytes, objSize;
+
+                oClass = __qClass(addr);
+                if (! __isBytes(addr) )
+                    goto bad;
+                nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
+                nInstBytes = OHDR_SIZE + (nInstVars * sizeof(OBJ));
+                objSize = __qSize(addr) - nInstBytes;
+                addrPtr = (char *)__InstPtr(addr) + nInstBytes;
+                if (objSize < alen)
+                    goto bad;
+
+                /*
+                 * extract the datagrams address
+                 */
+                memcpy(addrPtr, (char *)&sa, alen);
+                addrLen = __MKSMALLINT(alen);
+            }
+        }
+        if (n < 0) {
+            error = __INST(lastErrorNumber) = __MKSMALLINT(errno);
+        }
+        nReceived = __MKSMALLINT(n);
     }
 #endif
 bad: ;
 %}.
     error notNil ifTrue:[
-	^ ReadError
-	    raiseRequestWith:self
-	    errorString:(' : ' , OperatingSystem errorTextForNumber:error)
+        ^ self readError:error.
     ].
 
     nReceived notNil ifTrue:[
-	addrLen notNil ifTrue:[
-	    (addr == anAddressBuffer) ifFalse:[
-		self obsoleteFeatureWarning:'please use a socketAddress argument'.
-
-		"can be a ByteArray for backward compatibility"
-		anAddressBuffer replaceFrom:1 to:addrLen with:(addr hostAddress).
-	    ].
-	].
-	^ nReceived
+        addrLen notNil ifTrue:[
+            (addr == anAddressBuffer) ifFalse:[
+                self obsoleteFeatureWarning:'please use a socketAddress argument'.
+
+                "can be a ByteArray for backward compatibility"
+                anAddressBuffer replaceFrom:1 to:addrLen with:(addr hostAddress).
+            ].
+        ].
+        ^ nReceived
     ].
     "
      arrive here if you try to receive into an invalid buffer
@@ -2562,73 +2555,68 @@
     if ((fp != nil)
      && __isSmallInteger(startIndex)
      && __isSmallInteger(nBytes)) {
-	SOCKET sock;
-	INT objSize;
-	INT n;
-	char *extPtr;
-	INT _flags = 0;
-	INT offs;
-	unsigned long norder;
-	unsigned char *buffer;
-	unsigned char *allocatedBuffer = NULL;
-
-	_flags = __longIntVal(flags);
-
-	sock = SOCKET_FROM_FILE_OBJECT(fp);
-
-	if (! setupBufferParameters(aDataBuffer, startIndex, &extPtr, &offs, &objSize)) goto bad;
-	if (__isSmallInteger(nBytes)) {
-	    if (__intVal(nBytes) < objSize) {
-		objSize = __intVal(nBytes);
-	    }
-	}
+        SOCKET sock;
+        INT objSize, n, offs;
+        char *extPtr;
+        int _flags = __longIntVal(flags);
+        unsigned long norder;
+        unsigned char *buffer, *allocatedBuffer = NULL;
+
+        sock = SOCKET_FROM_FILE_OBJECT(fp);
+
+        if (! setupBufferParameters(aDataBuffer, startIndex, &extPtr, &offs, &objSize)) goto bad;
+        if (__isSmallInteger(nBytes)) {
+            if (__intVal(nBytes) < objSize) {
+                objSize = __intVal(nBytes);
+            }
+        }
 
 # ifdef DGRAM_DEBUG
-	console_printf("sending %d bytes ...\n", nBytes);
+        console_printf("sending %d bytes ...\n", nBytes);
 # endif
 
 #ifdef DO_WRAP_CALLS
-	if (extPtr) {
-	    buffer = extPtr + offs;
-	} else {
-	    allocatedBuffer = buffer = (char *)malloc(objSize);
-	    bcopy((char *)__InstPtr(aDataBuffer) + offs, allocatedBuffer, objSize);
-	}
-
-	do {
-	    __threadErrno = 0;
-	    n = (INT)STX_WSA_NOINT_CALL4("send", send, sock, buffer, objSize, _flags);
-	} while ((n < 0) && (__threadErrno == EINTR));
-	if (n < 0) {
-	    errno = __threadErrno;
-	}
-
-	if (allocatedBuffer) {
-	    free(allocatedBuffer);
-	}
+        if (extPtr) {
+            buffer = extPtr + offs;
+        } else {
+            allocatedBuffer = buffer = (char *)malloc(objSize);
+            bcopy((char *)__InstPtr(aDataBuffer) + offs, allocatedBuffer, objSize);
+        }
+
+        do {
+            __threadErrno = 0;
+            n = (INT)STX_WSA_NOINT_CALL4("send", send, sock, buffer, objSize, _flags);
+        } while ((n < 0) && (__threadErrno == EINTR));
+        if (n < 0) {
+            errno = __threadErrno;
+        }
+
+        if (allocatedBuffer) {
+            free(allocatedBuffer);
+        }
 #else
-	__BEGIN_INTERRUPTABLE__
-	do {
-	    if (extPtr) {
-		n = send(sock, extPtr + offs, objSize, _flags);
-	    } else {
-		n = send(sock, (char *)__InstPtr(aDataBuffer) + offs, objSize, _flags);
-	    }
-	} while ((n < 0) && (errno == EINTR));
-	__END_INTERRUPTABLE__
+        __BEGIN_INTERRUPTABLE__
+        do {
+            if (extPtr) {
+                n = send(sock, extPtr + offs, objSize, _flags);
+            } else {
+                n = send(sock, (char *)__InstPtr(aDataBuffer) + offs, objSize, _flags);
+            }
+        } while ((n < 0) && (errno == EINTR));
+        __END_INTERRUPTABLE__
 #endif
 
-	if (n < 0) {
-	    error = __INST(lastErrorNumber) = __MKSMALLINT(errno);
-	} else {
-	    RETURN (__MKSMALLINT(n));
-	}
+        if (n < 0) {
+            error = __INST(lastErrorNumber) = __MKSMALLINT(errno);
+        } else {
+            RETURN (__MKSMALLINT(n));
+        }
     }
 #endif
 bad: ;
 %}.
     error notNil ifTrue:[
-	self writeError:error.
+        self writeError:error.
     ].
 
     "
@@ -2676,16 +2664,16 @@
     |domainClass addr error|
 
     (anAddressBuffer isKindOf:SocketAddress) ifTrue:[
-	addr := anAddressBuffer.
+        addr := anAddressBuffer.
     ] ifFalse:[
-	anAddressBuffer isByteArray ifFalse:[
-	    ^ self error:'bad socketAddress argument'
-	].
-	domainClass := self class socketAddressClassForDomain:domain.
-	domainClass isNil ifTrue:[
-	    ^ self error:'invalid (unsupported) domain'.
-	].
-	addr := domainClass hostAddress:anAddressBuffer.
+        anAddressBuffer isByteArray ifFalse:[
+            ^ self error:'bad socketAddress argument'
+        ].
+        domainClass := self class socketAddressClassForDomain:domain.
+        domainClass isNil ifTrue:[
+            ^ self error:'invalid (unsupported) domain'.
+        ].
+        addr := domainClass hostAddress:anAddressBuffer.
     ].
 %{
 #ifndef NO_SOCKET
@@ -2694,92 +2682,90 @@
     if ((fp != nil)
      && __isSmallInteger(startIndex)
      && __isSmallInteger(nBytes)) {
-	SOCKET sock;
-	INT objSize;
-	struct sockaddr *sockaddr_ptr;
-	union sockaddr_u sa;
-	INT alen = 0;
-	INT sockAddrOffs, sockaddr_size;
-	INT n;
-	char *extPtr;
-	INT _flags = 0;
-	INT offs;
-	unsigned long norder;
-	unsigned char *buffer;
-	unsigned char *allocatedBuffer = NULL;
-
-	_flags = __longIntVal(flags);
-	sock = SOCKET_FROM_FILE_OBJECT(fp);
-
-	if (! __isBytes(addr)) {
-	    sockaddr_size = 0;
-	    sockaddr_ptr = (struct sockaddr *)0;
-	} else {
-	    int nIndex;
-	    OBJ cls;
-
-	    sockAddrOffs = 0;
-	    if ((cls = __qClass(addr)) != @global(ByteArray))
-		sockAddrOffs += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
-	    nIndex = __qSize(addr) - OHDR_SIZE;
-	    sockaddr_size = nIndex - sockAddrOffs;
-	    if (sockaddr_size > sizeof(sa)) {
-		console_fprintf(stderr, "Socket [warning]: bad socketAddr\n");
-		goto bad;
-	    }
-	    memcpy(&sa, (__byteArrayVal(addr) + sockAddrOffs), sockaddr_size);
-	    sockaddr_ptr = (struct sockaddr *)(&sa);
-	}
-
-	if (! setupBufferParameters(aDataBuffer, startIndex, &extPtr, &offs, &objSize)) goto bad;
-	if (__isSmallInteger(nBytes)) {
-	    if (__intVal(nBytes) < objSize) {
-		objSize = __intVal(nBytes);
-	    }
-	}
+        SOCKET sock;
+        INT objSize;
+        struct sockaddr *sockaddr_ptr;
+        union sockaddr_u sa;
+        socklen_t sockaddr_size, alen = 0;
+        INT sockAddrOffs; 
+        INT n, offs;
+        char *extPtr;
+        int _flags = __longIntVal(flags);
+        unsigned long norder;
+        unsigned char *buffer;
+        unsigned char *allocatedBuffer = NULL;
+
+        sock = SOCKET_FROM_FILE_OBJECT(fp);
+
+        if (! __isBytes(addr)) {
+            sockaddr_size = 0;
+            sockaddr_ptr = (struct sockaddr *)0;
+        } else {
+            int nIndex;
+            OBJ cls;
+
+            sockAddrOffs = 0;
+            if ((cls = __qClass(addr)) != @global(ByteArray))
+                sockAddrOffs += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+            nIndex = __qSize(addr) - OHDR_SIZE;
+            sockaddr_size = nIndex - sockAddrOffs;
+            if (sockaddr_size > sizeof(sa)) {
+                console_fprintf(stderr, "Socket [warning]: bad socketAddr\n");
+                goto bad;
+            }
+            memcpy(&sa, (__byteArrayVal(addr) + sockAddrOffs), sockaddr_size);
+            sockaddr_ptr = (struct sockaddr *)(&sa);
+        }
+
+        if (! setupBufferParameters(aDataBuffer, startIndex, &extPtr, &offs, &objSize)) goto bad;
+        if (__isSmallInteger(nBytes)) {
+            if (__intVal(nBytes) < objSize) {
+                objSize = __intVal(nBytes);
+            }
+        }
 
 #ifdef DO_WRAP_CALLS
-	if (extPtr) {
-	    buffer = extPtr + offs;
-	} else {
-	    allocatedBuffer = buffer = (char *)malloc(objSize);
-	    bcopy((char *)__InstPtr(aDataBuffer) + offs, allocatedBuffer, objSize);
-	}
-
-	do {
-	    __threadErrno = 0;
-	    n = (INT)STX_WSA_NOINT_CALL6("sendto", sendto, sock, buffer, objSize, _flags, sockaddr_ptr, sockaddr_size);
-	} while ((n < 0) && (__threadErrno == EINTR));
-	if (n < 0) {
-	    errno = __threadErrno;
-	}
-
-	if (allocatedBuffer) {
-	    free(allocatedBuffer);
-	}
+        if (extPtr) {
+            buffer = extPtr + offs;
+        } else {
+            allocatedBuffer = buffer = (char *)malloc(objSize);
+            bcopy((char *)__InstPtr(aDataBuffer) + offs, allocatedBuffer, objSize);
+        }
+
+        do {
+            __threadErrno = 0;
+            n = (INT)STX_WSA_NOINT_CALL6("sendto", sendto, sock, buffer, objSize, _flags, sockaddr_ptr, sockaddr_size);
+        } while ((n < 0) && (__threadErrno == EINTR));
+        if (n < 0) {
+            errno = __threadErrno;
+        }
+
+        if (allocatedBuffer) {
+            free(allocatedBuffer);
+        }
 #else
-	__BEGIN_INTERRUPTABLE__
-	do {
-	    if (extPtr) {
-		n = sendto(sock, extPtr + offs, objSize, _flags, sockaddr_ptr, sockaddr_size);
-	    } else {
-		n = sendto(sock, (char *)__InstPtr(aDataBuffer) + offs, objSize, _flags, sockaddr_ptr, sockaddr_size);
-	    }
-	} while ((n < 0) && (errno == EINTR));
-	__END_INTERRUPTABLE__
+        __BEGIN_INTERRUPTABLE__
+        do {
+            if (extPtr) {
+                n = sendto(sock, extPtr + offs, objSize, _flags, sockaddr_ptr, sockaddr_size);
+            } else {
+                n = sendto(sock, (char *)__InstPtr(aDataBuffer) + offs, objSize, _flags, sockaddr_ptr, sockaddr_size);
+            }
+        } while ((n < 0) && (errno == EINTR));
+        __END_INTERRUPTABLE__
 #endif
 
-	if (n < 0) {
-	    error = __INST(lastErrorNumber) = __MKSMALLINT(errno);
-	} else {
-	    RETURN (__MKSMALLINT(n));
-	}
+        if (n < 0) {
+            error = __INST(lastErrorNumber) = __MKSMALLINT(errno);
+        } else {
+            RETURN (__MKSMALLINT(n));
+        }
     }
 #endif
 bad: ;
 %}.
     error notNil ifTrue:[
-	self writeError:error.
+        self writeError:error.
     ].
 
     "
@@ -3815,7 +3801,6 @@
     "
 ! !
 
-
 !Socket methodsFor:'specials'!
 
 linger:anIntegerOrNil
@@ -4091,7 +4076,6 @@
     ^ self setSocketOption:#'TCP_NODELAY' argument:aBoolean argument:nil.
 ! !
 
-
 !Socket methodsFor:'waiting'!
 
 waitForNewConnectionOrDataOnAny:otherConnections timeout:timeoutSeconds