RTC Forums
March 28, 2024, 10:29:42 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: RtcHttpClient reuse address  (Read 2703 times)
twinsoft
RTC License
***
Posts: 15


« on: June 03, 2020, 12:08:32 PM »

Hi, we need to set the reuse socket property of the undelying socket to true, as we do in Indy with IdTcpClient.ReuseSocket := rsTrue. How can this be done with RtcHttpClient ?

Stefanos
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: June 03, 2020, 12:20:11 PM »

The "SO_REUSEADDR" flag is set by default for TRtcHttpClient components using the WinSock API (useProxy=False; useWinHTTP=False). You can check that by opening the "rtcWinSocket.pas" unit and looking at the "TRtcWinSocket.Connect" method implementation, where you will find this code block ...

  else { FProtoType = SOCK_STREAM }
    begin
    optval  := -1;
    iStatus := _setsockopt(FHSocket, SOL_SOCKET, SO_REUSEADDR, @optval, SizeOf(optval));
    if iStatus <> 0 then
      begin
      RealSocketError('setsockopt(SO_REUSEADDR)',False);
      Exit;
      end;

Best Regards,
Danijel Tkalcec
Logged
twinsoft
RTC License
***
Posts: 15


« Reply #2 on: June 03, 2020, 12:44:42 PM »

Hi, it is also set in TRtcSocket.Sock_SetDelay, which is used in TRtcSocket.Sock_Listen/TRtcSocket.Sock_Connect. This makes me believe that it is also set on other platfroms (apart from Windows). Is this correct ?

Stefanos
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 on: June 03, 2020, 12:51:22 PM »

Correct. As you've already found out, "SO_REUSEADDR" is set by default for all platforms in the "TRtcSocket.Sock_SetDelay" method in the "rtcSynAPI.pas" unit.

Best Regards,
Danijel Tkalcec
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.024 seconds with 16 queries.