--- a/Socket.st Mon Oct 25 14:21:27 2004 +0200
+++ b/Socket.st Tue Nov 09 18:28:58 2004 +0100
@@ -103,7 +103,7 @@
Due to historic reasons (I started this class, before I got hold of some
code using ST-80 Sockets i.e. RemoteInvocation), there is some old interface
- still provided.
+ still provided.
This will vanish; use the #family:type: or #newTCPxxx and #newUDPxxx interfaces,
together with the bind/listen and accept calls,
which are meant to be compatible to ST-80's UnixSocketAccessor interface.
@@ -211,7 +211,7 @@
[exBegin]
|connectSock sock|
- connectSock := Socket newTCPserverAtPort:9998.
+ connectSock := Socket newTCPserverAtPort:9998.
connectSock isNil ifTrue:[
Transcript showCR:'socket setup failed.'.
] ifFalse:[
@@ -220,7 +220,7 @@
Transcript showCR:'listen failed.'.
] ifTrue:[
Transcript showCR:'wait'.
- connectSock readWait.
+ connectSock readWait.
Transcript showCR:'accept'.
sock := connectSock accept.
sock isNil ifTrue:[
@@ -263,7 +263,7 @@
|connectSock sock|
'/tmp/ud_socket' asFilename remove.
- connectSock := Socket newUNIXserverAt:'/tmp/ud_socket'.
+ connectSock := Socket newUNIXserverAt:'/tmp/ud_socket'.
connectSock isNil ifTrue:[
Transcript showCR:'socket setup failed.'.
] ifFalse:[
@@ -273,7 +273,7 @@
] ifTrue:[
Transcript showCR:'wait'.
connectSock buffered:false.
- connectSock readWait.
+ connectSock readWait.
Transcript showCR:'accept'.
sock := connectSock accept.
sock isNil ifTrue:[
@@ -319,15 +319,15 @@
[exBegin]
|udpSock sock addr n dataBuffer|
- udpSock := Socket newUDPserverAtPort:9999.
+ udpSock := Socket newUDPserverAtPort:9999.
udpSock isNil ifTrue:[
Transcript showCR:'socket setup failed.'.
] ifFalse:[
Transcript showCR:'wait'.
- udpSock readWait.
+ udpSock readWait.
addr := IPSocketAddress new.
- dataBuffer := ByteArray new:1000.
+ dataBuffer := ByteArray new:1000.
n := udpSock receiveFrom:addr buffer:dataBuffer start:1 for:dataBuffer size.
n > 0 ifTrue:[
Transcript showCR:('got: ' , n printString , 'bytes from ' , addr printString).
@@ -414,8 +414,8 @@
hostName isNil ifTrue:[
hostName :='?'
].
- l add:(dottedName paddedTo:15 with:Character space)
- , ' '
+ l add:(dottedName paddedTo:15 with:Character space)
+ , ' '
, (hostName paddedTo:15 with:Character space)
, ' up & reachable'.
list list:l.
@@ -430,9 +430,9 @@
[exEnd]
- This example creates a simple UDP server that accepts
- single packets from anybody and broadcasts them to all
- clients that have connected so far.
+ This example creates a simple UDP server that accepts
+ single packets from anybody and broadcasts them to all
+ clients that have connected so far.
[exBegin]
| socket address buffer msgSize clients |
@@ -447,18 +447,18 @@
[
[true] whileTrue: [
(socket readWaitWithTimeoutMs: 200) ifFalse: [
- msgSize := socket
- receiveFrom: address
- buffer: buffer
- start: 1
+ msgSize := socket
+ receiveFrom: address
+ buffer: buffer
+ start: 1
for: buffer size.
clients add: address copy.
- clients do: [ :clientAddress |
- socket
- sendTo: clientAddress
- buffer: buffer
- start: 1
+ clients do: [ :clientAddress |
+ socket
+ sendTo: clientAddress
+ buffer: buffer
+ start: 1
for: msgSize]]
]
] valueNowOrOnUnwindDo:[
@@ -494,7 +494,7 @@
replySize := socket receiveFrom:address buffer:buffer.
replySize > 0 ifTrue: [
Transcript cr; nextPutAll: 'Server acknowledged: '.
- Transcript show: ((buffer copyFrom: 1 to: replySize) asString)
+ Transcript show: ((buffer copyFrom: 1 to: replySize) asString)
]
]
] valueNowOrOnUnwindDo: [socket close].
@@ -508,7 +508,7 @@
|readerTask readingSocket writingSocket|
readingSocket := self newTCPserverAtPort:9999.
- readerTask :=
+ readerTask :=
[
|connection|
@@ -521,7 +521,7 @@
connection close.
] fork.
- Delay waitForSeconds:1.
+ Delay waitForSeconds:1.
writingSocket := self newTCPclientToHost:(OperatingSystem getHostName) port:9999.
writingSocket nextPutLine:'Hello'.
writingSocket nextPutLine:'World'.
@@ -535,7 +535,7 @@
domain:domainSymbol type:type
"create a socket for domain and type -
neither any connect nor binding is done.
- Domain must be one of the symbols:
+ Domain must be one of the symbols:
#inet, #unix, #appletalk, #decnet, #xns, ...;
Type must be:
#stream, #datagram or #raw
@@ -557,14 +557,14 @@
new
"create a TCP socket"
- ^ super new buffered:false
+ ^ super new buffered:false
!
newTCP
"create a TCP socket - no binding or other setup is done,
neither connect nor connect-wait is done."
- ^ self new domain:#inet type:#stream
+ ^ self new domain:#inet type:#stream
"Socket newUDP"
!
@@ -592,7 +592,7 @@
"create a new TCP client socket connecting to a service.
Return a socket instance if ok, nil on failure.
Block until a connection is established (but only the current thread;
- not the whole smalltalk).
+ not the whole smalltalk).
See also: #newTCPclientToAddress:port:withTimeout:"
^ self newTCPclientToAddress:aHostAddress port:aService withTimeout:nil
@@ -611,7 +611,7 @@
"create a new TCP client socket connecting to a service.
Return a socket instance if ok, nil on failure.
Block until a connection is established (but only the current thread;
- not the whole smalltalk).
+ not the whole smalltalk).
See also: #newTCPclientToHost:port:withTimeout:"
^ self newTCPclientToHost:hostname port:aService withTimeout:nil
@@ -633,8 +633,8 @@
newSock := self newTCP.
newSock notNil ifTrue:[
- (newSock connectTo:hostname
- port:(self portOfService:aService protocol:'tcp')
+ (newSock connectTo:hostname
+ port:(self portOfService:aService protocol:'tcp')
withTimeout:millis
) ifFalse:[
newSock close.
@@ -726,18 +726,18 @@
If the system does not support unix domain sockets (i.e. VMS or MSDOS),
return nil."
- ^ self new domain:#unix type:#stream
+ ^ self new domain:#unix type:#stream
"
Socket newUNIX
"
!
-newUNIXclientTo:pathName
+newUNIXclientTo:pathName
"create a new UNIX client socket connecting to a pathname.
Return a socket instance if ok, nil on failure.
Block until a connection is established (but only the current thread;
- not the whole smalltalk).
+ not the whole smalltalk).
If the system does not support unix domain sockets (i.e. VMS or MSDOS),
return nil.
See also: #newUNIXclientTo:withTimeout:"
@@ -758,10 +758,10 @@
newSock := self newUNIX.
newSock notNil ifTrue:[
- (newSock connectTo:'localhost' port:pathName withTimeout:millis) ifFalse:[
- newSock close.
- ^ nil
- ]
+ (newSock connectTo:'localhost' port:pathName withTimeout:millis) ifFalse:[
+ newSock close.
+ ^ nil
+ ]
].
^ newSock
@@ -830,7 +830,7 @@
!Socket class methodsFor:'Compatibility-VW'!
-AF_INET
+AF_INET
^ #AF_INET
!
@@ -882,8 +882,8 @@
This is the reverse operation to #hostWithAppletalkAddress:.
WARNING: untested code - I have no appletalk to test this."
- NameLookupError
- handle:[:ex |
+ NameLookupError
+ handle:[:ex |
^ nil
]
do:[
@@ -900,8 +900,8 @@
This is is the reverse operation to #appletalkAddressOfHost:.
WARNING: untested code - I have no appletalk to test this."
- NameLookupError
- handle:[:ex |
+ NameLookupError
+ handle:[:ex |
^ nil
]
do:[
@@ -910,7 +910,7 @@
"
Socket appletalkAddressOfHost:'yourAppleHere'
- Socket hostWithAppletalkAddress:#[1 2 3]
+ Socket hostWithAppletalkAddress:#[1 2 3]
"
!
@@ -921,8 +921,8 @@
Nil is returned for an unknown host or if its not an internet host.
This is the reverse operation to #ipAddressOfHost:."
- NameLookupError
- handle:[:ex |
+ NameLookupError
+ handle:[:ex |
^ nil
]
do:[
@@ -930,14 +930,14 @@
]
"
- Socket ipAddressOfHost:'clam'
- Socket hostWithIpAddress:(Socket ipAddressOfHost:'clam')
- Socket ipAddressOfHost:'porty'
+ Socket ipAddressOfHost:'clam'
+ Socket hostWithIpAddress:(Socket ipAddressOfHost:'clam')
+ Socket ipAddressOfHost:'porty'
Socket hostWithIpAddress:(Socket ipAddressOfHost:'porty')
- Socket hostWithIpAddress:#[1 2 3 4]
- Socket hostWithIpAddress:#[127 0 0 1]
+ Socket hostWithIpAddress:#[1 2 3 4]
+ Socket hostWithIpAddress:#[127 0 0 1]
Socket hostWithIpAddress:(Socket ipAddressOfHost:'1.2.3.4')
- Socket hostWithIpAddress:(Socket ipAddressOfHost:'www.altavista.com')
+ Socket hostWithIpAddress:(Socket ipAddressOfHost:'www.altavista.com')
"
!
@@ -948,8 +948,8 @@
Nil is returned for an unknown host or if its not an internet host.
This is the reverse operation to #ipV6AddressOfHost:."
- NameLookupError
- handle:[:ex |
+ NameLookupError
+ handle:[:ex |
^ nil
]
do:[
@@ -957,12 +957,12 @@
]
"
- Socket ipV6AddressOfHost:'clam'
- Socket hostWithIpV6Address:(Socket ipAddressOfHost:'clam')
- Socket ipV6AddressOfHost:'porty'
- Socket hostWithIpV6Address:(Socket ipAddressOfHost:'porty')
- Socket hostWithIpV6Address:#[1 2 3 4 5 6 7 8 9 10 11 12 13 14]
- Socket ipV6AddressOfHost:'www.exept.de'
+ Socket ipV6AddressOfHost:'clam'
+ Socket hostWithIpV6Address:(Socket ipAddressOfHost:'clam')
+ Socket ipV6AddressOfHost:'porty'
+ Socket hostWithIpV6Address:(Socket ipAddressOfHost:'porty')
+ Socket hostWithIpV6Address:#[1 2 3 4 5 6 7 8 9 10 11 12 13 14]
+ Socket ipV6AddressOfHost:'www.exept.de'
"
!
@@ -972,8 +972,8 @@
If the host is unknown, return nil.
This is the reverse operation to #hostWithIpAddress:."
- NameLookupError
- handle:[:ex |
+ NameLookupError
+ handle:[:ex |
^ nil
]
do:[
@@ -981,14 +981,14 @@
]
"
- Socket ipAddressOfHost:'localhost'
- Socket ipAddressOfHost:'exept'
- Socket ipAddressOfHost:'1.2.3.4'
+ Socket ipAddressOfHost:'localhost'
+ Socket ipAddressOfHost:'exept'
+ Socket ipAddressOfHost:'1.2.3.4'
Socket ipAddressOfHost:'193.15.16.17'
- Socket ipAddressOfHost:'josef'
- Socket ipAddressOfHost:'styx.com'
- Socket hostWithIpAddress:(Socket ipAddressOfHost:'localhost')
- Socket ipAddressOfHost:(Socket hostWithIpAddress:'127.0.0.1')
+ Socket ipAddressOfHost:'josef'
+ Socket ipAddressOfHost:'styx.com'
+ Socket hostWithIpAddress:(Socket ipAddressOfHost:'localhost')
+ Socket ipAddressOfHost:(Socket hostWithIpAddress:'127.0.0.1')
"
!
@@ -998,8 +998,8 @@
If the host is unknown, return nil.
This is the reverse operation to #hostWithIpV6Address:."
- NameLookupError
- handle:[:ex |
+ NameLookupError
+ handle:[:ex |
^ nil
]
do:[
@@ -1007,23 +1007,23 @@
]
"
- Socket ipV6AddressOfHost:'localhost'
- Socket ipV6AddressOfHost:'exept'
- Socket ipV6AddressOfHost:'exept.exept.de'
- Socket ipV6AddressOfHost:'www.google.de'
- Socket ipV6AddressOfHost:'1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16'
- Socket ipV6AddressOfHost:'josef'
- Socket ipV6AddressOfHost:'styx.com'
- Socket hostWithIpV6Address:(Socket ipV6AddressOfHost:'localhost')
- Socket ipV6AddressOfHost:(Socket hostV6WithIpAddress:'127.0.0.1')
+ Socket ipV6AddressOfHost:'localhost'
+ Socket ipV6AddressOfHost:'exept'
+ Socket ipV6AddressOfHost:'exept.exept.de'
+ Socket ipV6AddressOfHost:'www.google.de'
+ Socket ipV6AddressOfHost:'1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16'
+ Socket ipV6AddressOfHost:'josef'
+ Socket ipV6AddressOfHost:'styx.com'
+ Socket hostWithIpV6Address:(Socket ipV6AddressOfHost:'localhost')
+ Socket ipV6AddressOfHost:(Socket hostV6WithIpAddress:'127.0.0.1')
"
! !
!Socket class methodsFor:'obsolete'!
connectTo:service on:host
- "standard & easy client setup:
- create new client tcp socket, bind and connect;
+ "standard & easy client setup:
+ create new client tcp socket, bind and connect;
return the socket.
The thread block (interruptable), until the connection is established."
@@ -1039,7 +1039,7 @@
!
provide:aService
- "standard & easy server setup:
+ "standard & easy server setup:
create a new TCP server socket providing a service."
<resource:#obsolete>
@@ -1154,9 +1154,9 @@
"
Socket portOfService:'finger'
- Socket portOfService:'nntp'
- Socket portOfService:'echo'
- Socket portOfService:'snmp'
+ Socket portOfService:'nntp'
+ Socket portOfService:'echo'
+ Socket portOfService:'snmp'
"
!
@@ -1240,11 +1240,11 @@
RETURN ( nil );
%}
"
- Socket protocolOfService:'finger'
- Socket protocolOfService:'nntp'
+ Socket protocolOfService:'finger'
+ Socket protocolOfService:'nntp'
Socket protocolOfService:'xxx'
Socket protocolOfService:79
- Socket protocolOfService:'snmp'
+ Socket protocolOfService:'snmp'
"
!
@@ -1326,7 +1326,7 @@
^ self
!
-ioConnection
+ioConnection
^ self
!
@@ -1341,7 +1341,7 @@
"ST-80 mimicry.
In ST-80, socket is not a stream, but referes to one.
ST-80 code therefore uses 'Socket readWriteStream' to access
- the actual stream.
+ the actual stream.
In ST/X, sockets inherit from stream, so
this method returns the receiver, for transparency"
@@ -1352,7 +1352,7 @@
"ST-80 mimicry.
In ST-80, socket is not a stream, but referes to one.
ST-80 code therefore uses 'Socket readStream' to access
- the actual stream.
+ the actual stream.
In ST/X, sockets inherit from stream, so
this method returns the receiver, for transparency"
@@ -1365,7 +1365,7 @@
"ST-80 mimicry.
In ST-80, socket is not a stream, but referes to one.
ST-80 code therefore uses 'Socket writeStream' to access
- the actual stream.
+ the actual stream.
In ST/X, sockets inherit from stream, so
this method returns the receiver, for transparency"
@@ -1399,7 +1399,7 @@
setOption: optionName value: optionValue
optionName = 'TCP_NODELAY' ifTrue:[
- ^ self setTCPNoDelay:optionValue
+ ^ self setTCPNoDelay:optionValue
].
self error:'unimplemented socketoption' mayProceed:true
!
@@ -1491,7 +1491,7 @@
receiveFrom:anAddressBuffer buffer:aDataBuffer
"receive datagramm data - put address of originating host into
- anAddressBuffer, data into aBuffer.
+ anAddressBuffer, data into aBuffer.
Both must be ByteArray-like. The addressBuffer must
provide space for a valid address for my domain (i.e. for inet, a 4-byte byteArray).
Return the number of bytes received, or a negative number on error.
@@ -1502,9 +1502,9 @@
!
receiveFrom:anAddressBuffer buffer:aDataBuffer start:startIndex for:nBytes
- "receive datagramm data
- - put address of originating host into anAddressBuffer, data into aBuffer.
- For backward compatibility, the addressBuffer may be a non-SocketAddress;
+ "receive datagramm data
+ - put address of originating host into anAddressBuffer, data into aBuffer.
+ For backward compatibility, the addressBuffer may be a non-SocketAddress;
then, it must be a byteArray with appropriate size for the addressBytes.
Return the number of bytes received, or a negative number on error.
@@ -1604,15 +1604,15 @@
if (n >= 0) {
if (__isNonNilObject(addr)) {
oClass = __qClass(addr);
- if (! __isBytes(addr) )
+ if (! __isBytes(addr) )
goto bad;
nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
nInstBytes = OHDR_SIZE + (nInstVars * sizeof(OBJ));
objSize = __qSize(addr) - nInstBytes;
cp = (char *)__InstPtr(addr) + nInstBytes;
- if (objSize < alen)
+ if (objSize < alen)
goto bad;
-
+
/*
* extract the datagrams address
*/
@@ -1645,15 +1645,15 @@
].
"
arrive here if you try to receive into an invalid buffer
- (i.e. not ByteArray-like),
- or if the addressBuffer is nonNil AND not a SocketAddress/ByteArray
+ (i.e. not ByteArray-like),
+ or if the addressBuffer is nonNil AND not a SocketAddress/ByteArray
or if the addressBuffer is nonNil AND too small.
"
self primitiveFailed
!
sendBuffer:aDataBuffer start:startIndex for:count flags:flags
- "send data.
+ "send data.
Both must be ByteArray-like. The bytes in the addressBuffer must
be a valid address for my domain (i.e. for inet, a 4-byte byteArray).
Return the number of bytes transmitted, or a negative number on error.
@@ -1675,8 +1675,8 @@
unsigned long norder;
_flags = __longIntVal(flags);
-
- if ((fp != nil)
+
+ if ((fp != nil)
&& __isSmallInteger(startIndex)
&& __isSmallInteger(count)) {
sock = fileno(__FILEVal(fp));
@@ -1747,14 +1747,14 @@
bad: ;
%}.
"
- arrive here if you try to send from an invalid buffer (i.e. not ByteArray-like),
+ arrive here if you try to send from an invalid buffer (i.e. not ByteArray-like),
"
self primitiveFailed
!
sendTo:anAddressBuffer buffer:buffer
"send datagramm data - fetch address of destination host from
- anAddressBuffer, data from aDataBuffer.
+ anAddressBuffer, data from aDataBuffer.
Both must be ByteArray-like. The bytes in the addressBuffer must
be a valid address for my domain (i.e. for inet, a 4-byte byteArray).
Return the number of bytes transmitted, or a negative number on error.
@@ -1762,12 +1762,12 @@
instance variable.
Flags is currently ignored; it is there for ST-80 compatibility."
- ^ self sendTo:anAddressBuffer buffer:buffer start:1 for:buffer size flags:0
+ ^ self sendTo:anAddressBuffer buffer:buffer start:1 for:buffer size flags:0
!
sendTo:anAddressBuffer buffer:buffer start:startIndex for:count
"send datagramm data - fetch address of destination host from
- anAddressBuffer, data from aDataBuffer.
+ anAddressBuffer, data from aDataBuffer.
Both must be ByteArray-like. The bytes in the addressBuffer must
be a valid address for my domain (i.e. for inet, a 4-byte byteArray).
Return the number of bytes transmitted, or a negative number on error.
@@ -1775,13 +1775,13 @@
instance variable.
Flags is currently ignored; it is there for ST-80 compatibility."
- ^ self sendTo:anAddressBuffer buffer:buffer start:startIndex for:count flags:0
+ ^ self sendTo:anAddressBuffer buffer:buffer start:startIndex for:count flags:0
!
sendTo:anAddressBuffer buffer:aDataBuffer start:startIndex for:count flags:flags
"send datagramm data - fetch address of destination host from
anAddressBuffer, data from aDataBuffer starting at startIndex,
- sending count bytes.
+ sending count bytes.
Both must be ByteArray-like. The bytes in the addressBuffer must
be a valid address for my domain (i.e. for inet, a 4-byte byteArray).
Return the number of bytes transmitted, or a negative number on error.
@@ -1809,7 +1809,7 @@
OBJ fp = __INST(filePointer);
int nInstVars, nInstBytes, objSize;
struct sockaddr *sockaddr_ptr;
- int sockAddrOffs, sockaddr_size;
+ int sockAddrOffs, sockaddr_size;
int sock;
int n;
char *cp;
@@ -1818,8 +1818,8 @@
unsigned long norder;
_flags = __longIntVal(flags);
-
- if ((fp != nil)
+
+ if ((fp != nil)
&& __isSmallInteger(startIndex)
&& __isSmallInteger(count)) {
sock = fileno(__FILEVal(fp));
@@ -1901,8 +1901,8 @@
%}.
"
arrive here if you try to send from an invalid buffer
- (i.e. not ByteArray-like),
- or if the addressBuffer is nonNil AND not a ByteArray/String
+ (i.e. not ByteArray-like),
+ or if the addressBuffer is nonNil AND not a ByteArray/String
or if the addressBuffer is nonNil AND too small.
"
self primitiveFailed
@@ -1924,7 +1924,7 @@
reuseAddress:false
!
-bindTo:aSocketAddress
+bindTo:aSocketAddress
"ST80 compatible bind, expecting a socketAddress argument.
The socketAddress object (an instance of SocketAddress)
is supposed to respond to #portOrName and #address requests."
@@ -1936,7 +1936,7 @@
bindTo:portNrOrNameString address:addressString
"low level bind - returns true if ok, false otherwise.
- Currently only non-address binding is supported;
+ Currently only non-address binding is supported;
i.e. the address must always be nil.
The interpretation of portNrOrName depends on the domain:
@@ -1945,15 +1945,15 @@
others use whatever will come up in the future
"
- ^ self
- bindTo:portNrOrNameString
- address:addressString
+ ^ self
+ bindTo:portNrOrNameString
+ address:addressString
reuseAddress:true
!
bindTo:portNrOrNameOrNil address:hostOrPathNameOrSocketAddrOrNil reuseAddress:reuse
"low level bind - returns true if ok, false otherwise.
- Currently only non-address binding is supported;
+ Currently only non-address binding is supported;
i.e. address must always be nil.
The interpretation of portNrOrName depends on the domain:
@@ -2006,7 +2006,7 @@
int sock;
union sockaddr_u sa;
struct sockaddr *sockaddr_ptr;
- int sockaddr_size;
+ int sockaddr_size;
int ret;
int on = 1;
int sockAddrOffs;
@@ -2117,7 +2117,7 @@
!Socket methodsFor:'low level'!
getSocketError
- "get the SO_ERROR form the socket, which indicates the
+ "get the SO_ERROR form the socket, which indicates the
result of an asynchronous operation"
%{
@@ -2185,7 +2185,7 @@
^ true
!
-shutDown
+shutDown
"shutDown and close the socket.
This does not wait for the data to be delivered."
@@ -2193,12 +2193,12 @@
self close
!
-shutdown: howNum
+shutdown: howNum
"shutDown the socket - inform it that no more I/O will be performed.
0 - read side (no further reads)
1 - write side (no further writes)
2 - both (no further I/O at all)
- shutDown:2
+ shutDown:2
discards any pending data (as opposed to close, which waits until data is delivered)"
filePointer isNil ifTrue:[^ self].
@@ -2358,8 +2358,8 @@
addrLen = __MKSMALLINT(alen);
}
- /*
- * make it a FILE *
+ /*
+ * make it a FILE *
*/
fp = fdopen(newSock, "r+");
if (! fp) {
@@ -2378,8 +2378,13 @@
__INST(buffered) = false;
# endif
- __INST(filePointer) = __MKOBJ(fp);
- __STORESELF(filePointer);
+ {
+ OBJ t;
+
+ t = __MKOBJ(fp);
+ __INST(filePointer) = t;
+ __STORE(self, t);
+ }
#endif /* not NO_SOCKET */
%}.
mode := #readwrite.
@@ -2401,7 +2406,7 @@
For an old connection, that socket is returned.
In any case, the caller gets a socket to operate on as return value,
or nil, if a timeout occured.
- This method implements the inner wait-primitive of a multi-connection
+ This method implements the inner wait-primitive of a multi-connection
server application."
"/ first, a quick check if data is already available
@@ -2438,7 +2443,7 @@
].
Processor signal:sema onInput:(self fileDescriptor).
timeoutSeconds notNil ifTrue:[
- Processor signal:sema afterSeconds:timeoutSeconds
+ Processor signal:sema afterSeconds:timeoutSeconds
].
Processor activeProcess state:#ioWait.
sema wait.
@@ -2467,7 +2472,7 @@
in at the receiver or a timeout occurs.
For a new connection, an accept is performed and the new socket is returned.
Returns nil, if a timeout occured.
- This method implements the inner wait-primitive of a single-connection
+ This method implements the inner wait-primitive of a single-connection
server application."
(self readWaitWithTimeout:timeoutSeconds) ifTrue:[
@@ -2569,13 +2574,13 @@
fcntl(sock, F_SETFL, oldFlags | O_NONBLOCK);
# endif
- /*
- * connect
+ /*
+ * connect
*/
__BEGIN_INTERRUPTABLE__
do {
ret = connect(sock, sockaddr_ptr, sockaddr_size);
- } while ((ret < 0)
+ } while ((ret < 0)
&& ((errno == EINTR)
# ifdef EAGAIN
|| (errno == EAGAIN)
@@ -2583,11 +2588,11 @@
));
__END_INTERRUPTABLE__
- if (ret < 0) {
+ if (ret < 0) {
# if defined(EINPROGRESS) || defined(EALREADY)
if (0
# ifdef EINPROGRESS
- || (errno == EINPROGRESS)
+ || (errno == EINPROGRESS)
# endif
# ifdef EALREADY
|| (errno == EALREADY)
@@ -2841,11 +2846,11 @@
int dom, typ, pf, proto = 0, sock;
int on = 1;
- if (! __isSmallInteger(domainCode)) {
+ if (! __isSmallInteger(domainCode)) {
DBGPRINTF(("SOCKET: bad domain\n"));
RETURN ( nil );
}
- if (! __isSmallInteger(typeCode)) {
+ if (! __isSmallInteger(typeCode)) {
DBGPRINTF(("SOCKET: bad type\n"));
RETURN ( nil );
}
@@ -2856,7 +2861,7 @@
}
proto = __intVal(protocolNumber);
}
-
+
/*
* get address and protocol-family
@@ -2892,8 +2897,8 @@
}
# endif /* SO_REUSEADDR */
- /*
- * make it a FILE *
+ /*
+ * make it a FILE *
*/
fp = fdopen(sock, "r+");
if (! fp) {
@@ -2908,8 +2913,13 @@
fprintf(stderr, "fdopen [Socket] -> %x\n", fp);
}
- __INST(filePointer) = __MKOBJ(fp);
- __STORESELF(filePointer);
+ {
+ OBJ t;
+
+ t = __MKOBJ(fp);
+ __INST(filePointer) = t;
+ __STORE(self, t);
+ }
}
}
#endif
@@ -3147,5 +3157,5 @@
!Socket class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/Socket.st,v 1.200 2004-09-06 23:27:31 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/Socket.st,v 1.201 2004-11-09 17:28:58 cg Exp $'
! !