Mark obsolete methods.
authorStefan Vogel <sv@exept.de>
Thu, 08 Nov 2007 15:04:43 +0100
changeset 1911 cb6a52d6944a
parent 1910 92504f2834ce
child 1912 18c701562016
Mark obsolete methods. Remove unused methods. bindTo:* now raises an error (as tryBindTo: did)
Socket.st
--- a/Socket.st	Thu Nov 08 15:03:27 2007 +0100
+++ b/Socket.st	Thu Nov 08 15:04:43 2007 +0100
@@ -706,17 +706,19 @@
 
     newSock := self newTCP.
     (newSock notNil and:[aServiceOrNil notNil]) ifTrue:[
-	[
-	    newSock tryToBindTo:(self portOfService:aServiceOrNil)
-	] ifCurtailed:[
-	    newSock close.
-	]
+        [
+            newSock bindTo:(self portOfService:aServiceOrNil) address:nil.
+        ] ifCurtailed:[
+            newSock close.
+        ]
     ].
     ^ newSock
 
 
-    "Socket newTCP:'nntp'"
-    "Socket newTCP:9995"
+    "
+        Socket newTCP:'nntp'.
+        Socket newTCP:9995.
+    "
 !
 
 newTCPclientToAddress:aHostAddress port:aService
@@ -796,17 +798,7 @@
 newTCPserverAtPort:aService
     "create a new TCP server socket providing service."
 
-    |newSock|
-
-    newSock := self newTCP.
-    newSock notNil ifTrue:[
-	[
-	    newSock tryToBindTo:(self portOfService:aService)
-	] ifCurtailed:[
-	    newSock close.
-	]
-    ].
-    ^ newSock
+    ^ self newTCP:aService
 !
 
 newUDP
@@ -826,35 +818,24 @@
 
     newSock := self newUDP.
     (newSock notNil and:[aServiceOrNil notNil]) ifTrue:[
-	[
-	    newSock tryToBindTo:(self portOfService:aServiceOrNil)
-	] ifCurtailed:[
-	    newSock close.
-	]
+        [
+            newSock bindTo:(self portOfService:aServiceOrNil) address:nil.
+        ] ifCurtailed:[
+            newSock close.
+        ]
     ].
     ^ newSock
 
-    "Socket newUDP:nil"
+    "
+        Socket newUDP:nil.
+        Socket newUDP:'rwho'.
+    "
 !
 
 newUDPserverAtPort:aService
     "create a new UDP server socket providing service."
 
-    |newSock|
-
-    newSock := self newUDP.
-    newSock notNil ifTrue:[
-	[
-	    newSock tryToBindTo:(self portOfService:aService)
-	] ifCurtailed:[
-	    newSock close.
-	]
-    ].
-    ^ newSock
-"
-same as:
-    ^ (self new) for:nil udpPort:aPort
-"
+    ^ self newUDP:aService
 !
 
 newUNIX
@@ -918,11 +899,11 @@
 
     newSock := self newUNIX.
     newSock notNil ifTrue:[
-	[
-	    newSock tryToBindTo:pathName
-	] ifCurtailed:[
-	    newSock close.
-	]
+        [
+            newSock bindTo:pathName address:nil.
+        ] ifCurtailed:[
+            newSock close.
+        ]
     ].
     ^ newSock
 
@@ -1019,9 +1000,69 @@
     "
 ! !
 
-!Socket class methodsFor:'host queries'!
+!Socket class methodsFor:'obsolete'!
+
+connectTo:service on:host
+    <resource: #obsolete>
+    "standard & easy client setup:
+        create new client tcp socket, bind and connect;
+        return the socket.
+     The thread blocks (interruptable), until the connection is established."
+
+    ^ self newTCPclientToHost:host port:(self portOfService:service).
+
+    "
+     Socket connectTo:9995 on:'clam'
+     Socket connectTo:4711 on:'exept'
+     Socket connectTo:'finger' on:'clam'
+     Socket connectTo:'ftp' on:'exept'
+     Socket connectTo:'nntp' on:(OperatingSystem getEnvironment:'NNTPSERVER')
+    "
+!
+
+networkLongOrderIsMSB
+    "return the well known fact, that network byte order is most significant byte first"
+
+    <resource: #obsolete>
+
+    ^ true
+!
+
+networkShortOrderIsMSB
+    "return the well known fact, that network byte order is most significant byte first"
+
+    <resource: #obsolete>
+
+    ^ true
+!
+
+provide:aService
+    "standard & easy server setup:
+     create a new TCP server socket providing a service."
+
+    <resource:#obsolete>
+
+    |newSock|
+
+    self obsoleteMethodWarning:'use #newTCPserverAtPort: / #listen'.
+
+    newSock := self newTCPserverAtPort:(self portOfService:aService).
+    newSock notNil ifTrue:[
+	newSock listenFor:5.
+    ].
+    ^ newSock
+
+    "
+     Socket provide:9995
+     (Socket provide:9996) accept
+     Socket provide:'nntp'
+    "
+! !
+
+!Socket class methodsFor:'obsolete host queries'!
 
 appletalkAddressOfHost:aHostName
+    <resource: #obsolete>
     "return the APPLETALK address for a hostname as a byteArray,
      where the network bytes come first (no matter what the local byteorder is)
      followed by the node byte.
@@ -1039,6 +1080,7 @@
 !
 
 hostWithAppletalkAddress:addrByteArray
+    <resource: #obsolete>
     "return the hostname for an APPLETALK address.
      The address is supposed to be a byteArray consisting of 3 bytes,
      the network bytes come first (no matter what the local byteorder is).
@@ -1062,6 +1104,7 @@
 !
 
 hostWithIpAddress:addrByteArray
+    <resource: #obsolete>
     "return the hostname for an IP (internet-) address.
      The address is supposed to be a byteArray consisting of 4 bytes,
      the network bytes come first (no matter what the local byteorder is).
@@ -1089,6 +1132,7 @@
 !
 
 hostWithIpV6Address:addrByteArray
+    <resource: #obsolete>
     "return the hostname for an IPv6 (internet-) address.
      The address is supposed to be a byteArray consisting ??? bytes,
      the network bytes come first (no matter what the local byteorder is).
@@ -1114,6 +1158,7 @@
 !
 
 ipAddressOfHost:aHostName
+    <resource: #obsolete>
     "return the IP (internet-) number for a hostname as a byteArray,
      where the network bytes come first (no matter what the cpus byteOrder is).
      If the host is unknown, return nil.
@@ -1140,6 +1185,7 @@
 !
 
 ipV6AddressOfHost:aHostName
+    <resource: #obsolete>
     "return the IPv6 (internet-) number for a hostname as a byteArray,
      where the network bytes come first (no matter what the cpus byteOrder is).
      If the host is unknown, return nil.
@@ -1166,48 +1212,6 @@
     "
 ! !
 
-!Socket class methodsFor:'obsolete'!
-
-connectTo:service on:host
-    "standard & easy client setup:
-	create new client tcp socket, bind and connect;
-	return the socket.
-     The thread blocks (interruptable), until the connection is established."
-
-    ^ self newTCPclientToHost:host port:(self portOfService:service).
-
-    "
-     Socket connectTo:9995 on:'clam'
-     Socket connectTo:4711 on:'exept'
-     Socket connectTo:'finger' on:'clam'
-     Socket connectTo:'ftp' on:'exept'
-     Socket connectTo:'nntp' on:(OperatingSystem getEnvironment:'NNTPSERVER')
-    "
-!
-
-provide:aService
-    "standard & easy server setup:
-     create a new TCP server socket providing a service."
-
-    <resource:#obsolete>
-
-    |newSock|
-
-    self obsoleteMethodWarning:'use #newTCPserverAtPort: / #listen'.
-
-    newSock := self newTCPserverAtPort:(self portOfService:aService).
-    newSock notNil ifTrue:[
-	newSock listenFor:5.
-    ].
-    ^ newSock
-
-    "
-     Socket provide:9995
-     (Socket provide:9996) accept
-     Socket provide:'nntp'
-    "
-! !
-
 !Socket class methodsFor:'queries'!
 
 domainOfProtocol:aProtocol
@@ -1244,22 +1248,6 @@
     "
 !
 
-networkLongOrderIsMSB
-    "return the well known fact, that network byte order is most significant byte first"
-
-    <resource: #obsolete>
-
-    ^ true
-!
-
-networkShortOrderIsMSB
-    "return the well known fact, that network byte order is most significant byte first"
-
-    <resource: #obsolete>
-
-    ^ true
-!
-
 peerFromDomain:domain name:peerName port:port
     |addrClass|
 
@@ -2150,49 +2138,48 @@
      i.e. address must always be nil.
 
      The interpretation of portNrOrName depends on the domain:
-	inet domain uses (4byte) byteArray like internet numbers,
-	unix domain uses pathname strings,
-	others use whatever will come up in the future
+        inet domain uses (4byte) byteArray like internet numbers,
+        unix domain uses pathname strings,
+        others use whatever will come up in the future
 
      The reuse boolean argument controls if the SO_REUSEADDR socket option
      is to be set (to avoid the 'bind: address in use' error).
     "
 
-    |ok addr addrName domainClass|
+    |ok addr addrName domainClass error|
 
     filePointer isNil ifTrue:[
-	^ self errorNotOpen
+        ^ self errorNotOpen
     ].
 
     domainClass := self class socketAddressClassForDomain:domain.
     domainClass isNil ifTrue:[
-	^ self error:'invalid (unsupported) domain'.
+        ^ self error:'invalid (unsupported) domain'.
     ].
 
-    " backward compatibility: support for byteArray and string arg "
-
     hostOrPathNameOrSocketAddrOrNil isNil ifTrue:[
-	addr := domainClass anyHost.
+        addr := domainClass anyHost.
     ] ifFalse:[
-	hostOrPathNameOrSocketAddrOrNil isString ifTrue:[
-	    addr := domainClass hostName:hostOrPathNameOrSocketAddrOrNil.
-	    addrName := hostOrPathNameOrSocketAddrOrNil.
-	] ifFalse:[
-	    (hostOrPathNameOrSocketAddrOrNil isKindOf:SocketAddress) ifTrue:[
-		addr := hostOrPathNameOrSocketAddrOrNil.
-	    ] ifFalse:[
-		hostOrPathNameOrSocketAddrOrNil isByteArray ifFalse:[
-		    ^ self error:'bad host (socketAddress) argument'
-		].
-		addr := domainClass hostAddress:hostOrPathNameOrSocketAddrOrNil.
-	    ].
-	].
+        (hostOrPathNameOrSocketAddrOrNil isKindOf:SocketAddress) ifTrue:[
+            addr := hostOrPathNameOrSocketAddrOrNil.
+        ] ifFalse:[
+            "backward compatibility: support for byteArray and string arg"
+            hostOrPathNameOrSocketAddrOrNil isString ifTrue:[
+                addr := domainClass hostName:hostOrPathNameOrSocketAddrOrNil.
+                addrName := hostOrPathNameOrSocketAddrOrNil.
+            ] ifFalse:[
+                hostOrPathNameOrSocketAddrOrNil isByteArray ifFalse:[
+                    ^ self error:'bad host (socketAddress) argument'
+                ].
+                addr := domainClass hostAddress:hostOrPathNameOrSocketAddrOrNil.
+            ].
+        ].
     ].
     portNrOrNameOrNil notNil ifTrue:[
-	addr port:portNrOrNameOrNil.
+        addr port:portNrOrNameOrNil.
     ].
     (portNrOrNameOrNil isNil or:[portNrOrNameOrNil == 0]) ifTrue:[
-	addr := addr copy.
+        addr := addr copy.
     ].
 
 %{  /* STACK: 100000 */
@@ -2200,91 +2187,96 @@
     OBJ fp = __INST(filePointer);
 
     if (! __isBytes(addr)) {
-	addr = nil;
-	console_fprintf(stderr, "Socket [warning]: bad sddr\n");
-	RETURN (false);
+        error=__mkSmallInteger(-1);
+        addr = nil;
+        goto getOutOfHere;
     }
     if (fp != nil) {
-	SOCKET sock;
-	union sockaddr_u sa;
-	int sockaddr_size;
-	int ret;
-	int sockAddrOffs;
-
-	{
-	    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: bad socketAddr\n");
-		RETURN (false);
-	    }
-	    bcopy((__byteArrayVal(addr) + sockAddrOffs), &sa, sockaddr_size);
-	}
-
-	sock = SOCKET_FROM_FILE_OBJECT(fp);
+        SOCKET sock;
+        union sockaddr_u sa;
+        int sockaddr_size;
+        int ret;
+        int sockAddrOffs;
+
+        {
+            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)) {
+                error=__mkSmallInteger(-2);
+                goto getOutOfHere;
+            }
+            memcpy(&sa, __byteArrayVal(addr) + sockAddrOffs, sockaddr_size);
+        }
+
+        sock = SOCKET_FROM_FILE_OBJECT(fp);
 
 # ifdef SO_REUSEADDR
-	if (reuse == true) {
-	    int on = 1;
-
-	    if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof (on)) < 0) {
-		DBGPRINTF(("SOCKET: setsockopt - SO_REUSEADDR failed\n"));
-	    }
-	}
+        if (reuse == true) {
+            int on = 1;
+
+            if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof (on)) < 0) {
+                DBGPRINTF(("SOCKET: setsockopt - SO_REUSEADDR failed\n"));
+            }
+        }
 # endif /* SO_REUSEADDR */
 
 # ifdef BIND_BLOCKS
 #  ifdef DO_WRAP_CALLS
-	do {
-	    __threadErrno = 0;
-	    ret = STX_WSA_CALL3("bind", bind, sock, &sa, sockaddr_size);
-	} while ((ret < 0) && (__threadErrno == EINTR));
+        do {
+            __threadErrno = 0;
+            ret = STX_WSA_CALL3("bind", bind, sock, &sa, sockaddr_size);
+        } while ((ret < 0) && (__threadErrno == EINTR));
 #  else
-	__BEGIN_INTERRUPTABLE__
-	do {
-	    ret = bind(sock, (struct sockaddr *)&sa, sockaddr_size);
-	} while ((ret < 0) && (errno == EINTR));
-	__END_INTERRUPTABLE__
+        __BEGIN_INTERRUPTABLE__
+        do {
+            ret = bind(sock, (struct sockaddr *)&sa, sockaddr_size);
+        } while ((ret < 0) && (errno == EINTR));
+        __END_INTERRUPTABLE__
 #  endif
 # else
-	ret = bind(sock, (struct sockaddr *)&sa, sockaddr_size);
+        ret = bind(sock, (struct sockaddr *)&sa, sockaddr_size);
 # endif
-	if (ret < 0) {
-	    DBGPRINTF(("SOCKET: bind failed errno=%d\n", errno));
-	    __INST(lastErrorNumber) = __MKSMALLINT(errno);
-	    RETURN (false);
-	} else {
-	    ok = true;
-
-	    if (! __isSmallInteger(portNrOrNameOrNil)
-		|| (portNrOrNameOrNil == __MKSMALLINT(0))) {
-		unsigned int alen = sockaddr_size;
-
-		/*
-		 * anonymous port - get the actual portNr
-		 */
-		if (getsockname(sock, (struct sockaddr *)&sa, &alen) < 0) {
+        if (ret < 0) {
+            DBGPRINTF(("SOCKET: bind failed errno=%d\n", errno));
+            error = __INST(lastErrorNumber) = __MKSMALLINT(errno);
+            goto getOutOfHere;
+        } else {
+            ok = true;
+
+            if (! __isSmallInteger(portNrOrNameOrNil)
+                || (portNrOrNameOrNil == __MKSMALLINT(0))) {
+                unsigned int alen = sockaddr_size;
+
+                /*
+                 * anonymous port - get the actual portNr
+                 */
+                if (getsockname(sock, (struct sockaddr *)&sa, &alen) < 0) {
 # ifdef WIN32
-		    errno = WSAGetLastError();
+                    errno = WSAGetLastError();
 # endif
-		    console_fprintf(stderr, "SOCKET: cannot get socketname: %d\n", errno);
-		}
-		bcopy(&sa, (__byteArrayVal(addr) + sockAddrOffs), alen);
-	    }
-	}
+                    console_fprintf(stderr, "SOCKET: cannot get socketname: %d\n", errno);
+                }
+                memcpy(__byteArrayVal(addr) + sockAddrOffs, &sa, alen);
+            }
+        }
     }
 #endif /* NO_SOCKET */
 
 getOutOfHere: ;
 %}.
     ok ~~ true ifTrue:[
-	^ false
+        "maybe someone catches the error and binds to some other port..."
+        OpenError raiseRequestWith:self errorString:('cannot bind socket to port: <1p> address: <2p> (error=<3p>)' 
+                                                        expandMacrosWith:portNrOrNameOrNil 
+                                                        with:hostOrPathNameOrSocketAddrOrNil
+                                                        with:error).
+        ^ true.
     ].
 
     peer := addr.
@@ -2295,8 +2287,8 @@
 
     "
      (Socket domain:#inet type:#stream)
-	 bindTo:9999
-	 address:nil
+         bindTo:21
+         address:nil
     "
 ! !
 
@@ -2677,13 +2669,6 @@
     }
 #endif
 %}.
-!
-
-tryToBindTo:portNrOrNameOrNil
-    (self bindTo:portNrOrNameOrNil address:nil) ifFalse:[
-	^ OpenError raiseWith:self errorString:('cannot bind socket to port: <1p>' expandMacrosWith:portNrOrNameOrNil).
-    ].
-    ^ self.
 ! !
 
 !Socket methodsFor:'low level-accepting'!
@@ -3081,31 +3066,30 @@
     |isAsync err domainClass addr addrName|
 
     filePointer isNil ifTrue:[
-	^ self errorNotOpen
-    ].
-
-    domainClass := self class socketAddressClassForDomain:domain.
-    domainClass isNil ifTrue:[
-	^ self error:'invalid (unsupported) domain'.
+        ^ self errorNotOpen
     ].
 
-    "/ backward compatibility: support for byteArray and string arg
-
-    hostOrPathNameOrSocketAddr isString ifTrue:[
-	addr := domainClass hostName:hostOrPathNameOrSocketAddr port:portNrOrNameOrNil.
-	addrName := hostOrPathNameOrSocketAddr.
+    (hostOrPathNameOrSocketAddr isKindOf:SocketAddress) ifTrue:[
+        addr := hostOrPathNameOrSocketAddr.
+        portNrOrNameOrNil notNil ifTrue:[
+            addr port:portNrOrNameOrNil.
+        ].
     ] ifFalse:[
-	hostOrPathNameOrSocketAddr isByteCollection ifFalse:[
-	    ^ self error:'bad host (socketAddress) argument'
-	].
-	(hostOrPathNameOrSocketAddr isKindOf:SocketAddress) ifTrue:[
-	    addr := hostOrPathNameOrSocketAddr.
-	    portNrOrNameOrNil notNil ifTrue:[
-		addr port:portNrOrNameOrNil.
-	    ].
-	] ifFalse:[
-	    addr := domainClass hostAddress:hostOrPathNameOrSocketAddr port:portNrOrNameOrNil.
-	].
+        "backward compatibility: support for byteArray and string arg"
+        domainClass := self class socketAddressClassForDomain:domain.
+        domainClass isNil ifTrue:[
+            ^ self error:'invalid (unsupported) domain'.
+        ].
+
+        hostOrPathNameOrSocketAddr isString ifTrue:[
+            addr := domainClass hostName:hostOrPathNameOrSocketAddr port:portNrOrNameOrNil.
+            addrName := hostOrPathNameOrSocketAddr.
+        ] ifFalse:[
+            hostOrPathNameOrSocketAddr isByteCollection ifFalse:[
+                ^ self error:'bad host (socketAddress) argument'
+            ].
+            addr := domainClass hostAddress:hostOrPathNameOrSocketAddr port:portNrOrNameOrNil.
+        ].
     ].
 
 %{  /* STACK: 100000 */
@@ -3120,24 +3104,24 @@
     int sockaddr_size;
 
     if (!__isNonNilObject(addr) || !__isBytes(addr)) {
-	DBGPRINTF(("SOCKET: invalid addrBytes\n"));
-	RETURN (false);
+        DBGPRINTF(("SOCKET: invalid addrBytes\n"));
+        RETURN (false);
     }
 
     {
-	int sockAddrOffs, 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: bad socketAddr\n");
-	    RETURN (false);
-	}
-	bcopy((__byteArrayVal(addr) + sockAddrOffs), &sa, sockaddr_size);
+        int sockAddrOffs, 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: bad socketAddr\n");
+            RETURN (false);
+        }
+        bcopy((__byteArrayVal(addr) + sockAddrOffs), &sa, sockaddr_size);
     }
 
     sock = SOCKET_FROM_FILE_OBJECT(fp);
@@ -3158,59 +3142,59 @@
      */
 # ifdef DO_WRAP_CALLS
     do {
-	DBGFPRINTF((stderr, "SOCKET: connect...\n"));
-	__threadErrno = 0;
-	ret = STX_WSA_NOINT_CALL3("connect", connect, sock, &sa, sockaddr_size);
-	DBGFPRINTF((stderr, "SOCKET: connect(%d) -> %d (%d)\n", sock, ret, __threadErrno));
+        DBGFPRINTF((stderr, "SOCKET: connect...\n"));
+        __threadErrno = 0;
+        ret = STX_WSA_NOINT_CALL3("connect", connect, sock, &sa, sockaddr_size);
+        DBGFPRINTF((stderr, "SOCKET: connect(%d) -> %d (%d)\n", sock, ret, __threadErrno));
     } while ((ret < 0) && (__threadErrno == EINTR));
 # else
     __BEGIN_INTERRUPTABLE__
     do {
-	ret = connect(sock, (struct sockaddr *)&sa, sockaddr_size);
+        ret = connect(sock, (struct sockaddr *)&sa, sockaddr_size);
     } while ((ret < 0)
-	     && ((errno == EINTR)
+             && ((errno == EINTR)
 # ifdef EAGAIN
-		 || (errno == EAGAIN)
+                 || (errno == EAGAIN)
 # endif
-		));
+                ));
     __END_INTERRUPTABLE__
 #endif
 
     if (ret < 0) {
 # if defined(EINPROGRESS) || defined(EALREADY)
-	if (0
+        if (0
 #  ifdef EINPROGRESS
-	    || (errno == EINPROGRESS)
+            || (errno == EINPROGRESS)
 #  endif
 #  ifdef EALREADY
-	    || (errno == EALREADY)
+            || (errno == EALREADY)
 #  endif
-	) {
-	    /*
-	     * This was a nonblocking operation that will take some time.
-	     * Do a select on read to get informed when the operation is ready.
-	     */
-	    DBGFPRINTF((stderr, "SOCKET: isAsync is true\n"));
-	    isAsync = true;
-	} else
+        ) {
+            /*
+             * This was a nonblocking operation that will take some time.
+             * Do a select on read to get informed when the operation is ready.
+             */
+            DBGFPRINTF((stderr, "SOCKET: isAsync is true\n"));
+            isAsync = true;
+        } else
 # endif /* EINPROGRESS or EALREADY */
-	{
-	    DBGFPRINTF((stderr, "SOCKET: connect failed ret=%d errno=%d __threadErrno=%d\n",
-			ret, errno, __threadErrno ));
+        {
+            DBGFPRINTF((stderr, "SOCKET: connect failed ret=%d errno=%d __threadErrno=%d\n",
+                        ret, errno, __threadErrno ));
 # ifdef DUMP_ADDRESS
-	    {
-		char *cp = (char *)(&sa);
-		int i;
-
-		console_printf("address data:\n");
-		for (i=0; i<sockaddr_size; i++) {
-		    console_printf(" %02x\n", *cp++);
-		}
-	    }
+            {
+                char *cp = (char *)(&sa);
+                int i;
+
+                console_printf("address data:\n");
+                for (i=0; i<sockaddr_size; i++) {
+                    console_printf(" %02x\n", *cp++);
+                }
+            }
 # endif
-	    __INST(lastErrorNumber) = __MKSMALLINT(errno);
-	    RETURN (false);
-	}
+            __INST(lastErrorNumber) = __MKSMALLINT(errno);
+            RETURN (false);
+        }
     }
 
 # if defined(O_NONBLOCK)
@@ -3224,16 +3208,16 @@
 # endif /* NO_SOCKET */
 %}.
     isAsync == true ifTrue:[
-	(self writeWaitWithTimeoutMs:timeout) ifTrue:[
-	    "/ a timeout occured
-	    "/ should cancel the connect?
-	    ^ false.
-	].
-	err := self getSocketError.
-	err ~~ 0 ifTrue:[
-	    lastErrorNumber := err.
-	    ^ false.
-	].
+        (self writeWaitWithTimeoutMs:timeout) ifTrue:[
+            "/ a timeout occured
+            "/ should cancel the connect?
+            ^ false.
+        ].
+        err := self getSocketError.
+        err ~~ 0 ifTrue:[
+            lastErrorNumber := err.
+            ^ false.
+        ].
     ].
     port := portNrOrNameOrNil.
     peer := addr.
@@ -4017,5 +4001,5 @@
 !Socket class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Socket.st,v 1.241 2007-06-04 20:27:09 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/Socket.st,v 1.242 2007-11-08 14:04:43 stefan Exp $'
 ! !