sockopt utilities added
authorClaus Gittinger <cg@exept.de>
Wed, 22 Oct 2003 20:59:47 +0200
changeset 1335 0fafb78d7a80
parent 1334 d5a43c7a11a6
child 1336 c87802bc34c3
sockopt utilities added
Socket.st
--- a/Socket.st	Tue Oct 21 09:21:31 2003 +0200
+++ b/Socket.st	Wed Oct 22 20:59:47 2003 +0200
@@ -3451,6 +3451,55 @@
 
 !Socket methodsFor:'specials'!
 
+receiveBufferSize
+    "get the send buffer size - for special applications only.
+     Not all operatingSystems offer this functionality
+     (returns nil, if unsupported)"
+
+    filePointer isNil ifTrue:[
+        ^ self errorNotOpen
+    ].
+%{
+#if defined(SO_RCVBUF) && defined(SOL_SOCKET)
+    {
+        OBJ fp = __INST(filePointer);
+        int sock;
+        int opt;
+
+        sock = fileno(__FILEVal(fp));
+        getsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char *)&opt, sizeof(int));
+        RETURN( __MKSMALLINT(opt) );
+    }
+#endif
+%}.
+    ^ nil
+!
+
+receiveBufferSize:size
+    "set the receive buffer size - for special applications only.
+     Not all operatingSystems offer this functionality
+     (returns false, if unsupported)"
+
+    filePointer isNil ifTrue:[
+        ^ self errorNotOpen
+    ].
+%{
+#if defined(SO_RCVBUF) && defined(SOL_SOCKET)
+    if (__isSmallInteger(size)) {
+        OBJ fp = __INST(filePointer);
+        int sock;
+        int opt;
+
+        sock = fileno(__FILEVal(fp));
+        opt = __intVal(size);
+        setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char *)&opt, sizeof(int));
+        RETURN(true);
+    }
+#endif
+%}.
+    ^ false
+!
+
 receiveTimeout:seconds
     "set the receive timeout - for special applications only.
      Not all operatingSystems offer this functionality
@@ -3479,6 +3528,55 @@
     ^ false
 !
 
+sendBufferSize
+    "get the send buffer size - for special applications only.
+     Not all operatingSystems offer this functionality
+     (returns nil, if unsupported)"
+
+    filePointer isNil ifTrue:[
+        ^ self errorNotOpen
+    ].
+%{
+#if defined(SO_SNDBUF) && defined(SOL_SOCKET)
+    {
+        OBJ fp = __INST(filePointer);
+        int sock;
+        int opt;
+
+        sock = fileno(__FILEVal(fp));
+        getsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char *)&opt, sizeof(int));
+        RETURN( __MKSMALLINT(opt) );
+    }
+#endif
+%}.
+    ^ nil
+!
+
+sendBufferSize:size
+    "set the send buffer size - for special applications only.
+     Not all operatingSystems offer this functionality
+     (returns false, if unsupported)"
+
+    filePointer isNil ifTrue:[
+        ^ self errorNotOpen
+    ].
+%{
+#if defined(SO_SNDBUF) && defined(SOL_SOCKET)
+    if (__isSmallInteger(size)) {
+        OBJ fp = __INST(filePointer);
+        int sock;
+        int opt;
+
+        sock = fileno(__FILEVal(fp));
+        opt = __intVal(size);
+        setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char *)&opt, sizeof(int));
+        RETURN(true);
+    }
+#endif
+%}.
+    ^ false
+!
+
 sendTimeout:seconds
     "set the send timeout - for special applications only.
      Not all operatingSystems offer this functionality
@@ -3510,5 +3608,5 @@
 !Socket class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Socket.st,v 1.188 2003-09-12 13:38:11 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/Socket.st,v 1.189 2003-10-22 18:59:47 cg Exp $'
 ! !