RTC Forums

Subscription => Support => Topic started by: twinsoft on June 03, 2020, 12:08:32 PM



Title: RtcHttpClient reuse address
Post by: twinsoft 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


Title: Re: RtcHttpClient reuse address
Post by: D.Tkalcec (RTC) 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


Title: Re: RtcHttpClient reuse address
Post by: twinsoft 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


Title: Re: RtcHttpClient reuse address
Post by: D.Tkalcec (RTC) 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