Hello,

Linux supports SO_SNDTIMEO and SO_RCVTIMEO but the parameter should be a struct timeval and not an integer like under windows. The attached patch fixes it, it should also work on other unix/bsd variants, but I only tested it under Linux.

Bye
--
Luca
--- blcksock.pas.orig   2009-06-01 18:17:04.000000000 +0200
+++ blcksock.pas        2009-06-01 19:09:28.000000000 +0200
@@ -1508,6 +1508,9 @@
   li: TLinger;
   x: integer;
   buf: TMemory;
+  {$IFNDEF WIN32}
+  timeval: TTimeval;
+  {$ENDIF}
 begin
   case value.Option of
     SOT_Linger:
@@ -1555,8 +1558,15 @@
         {$ELSE}
         buf := @Value.Value;
         {$ENDIF}
+        {$IFDEF WIN32}
         synsock.SetSockOpt(FSocket, integer(SOL_SOCKET), integer(SO_RCVTIMEO),
           buf, SizeOf(Value.Value));
+        {$ELSE}
+        timeval.tv_sec:=Value.Value div 1000;
+        timeval.tv_usec:=(Value.Value mod 1000) * 1000;
+        synsock.SetSockOpt(FSocket, integer(SOL_SOCKET), integer(SO_RCVTIMEO),
+          @timeval, SizeOf(timeval));
+        {$ENDIF}  
       end;
     SOT_SendTimeout:
       begin
@@ -1565,8 +1575,15 @@
         {$ELSE}
         buf := @Value.Value;
         {$ENDIF}
+        {$IFDEF WIN32}
         synsock.SetSockOpt(FSocket, integer(SOL_SOCKET), integer(SO_SNDTIMEO),
           buf, SizeOf(Value.Value));
+        {$ELSE}
+        timeval.tv_sec:=Value.Value div 1000;
+        timeval.tv_usec:=(Value.Value mod 1000) * 1000;
+        synsock.SetSockOpt(FSocket, integer(SOL_SOCKET), integer(SO_SNDTIMEO),
+          @timeval, SizeOf(timeval));
+        {$ENDIF}  
       end;
     SOT_Reuse:
       begin
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
synalist-public mailing list
synalist-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synalist-public

Reply via email to