-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to compile multiplatform #31
Comments
I have the same issue. What I did is : function TncLine.GetReceiveTimeout: Integer;
var
Opt: Cardinal;
OptSize: {$IFDEF MSWINDOWS}Integer{$ELSE}socklen_t{$ENDIF};
begin
OptSize := SizeOf(Opt);
{$IFDEF MSWINDOWS}
Check(GetSockOpt(FHandle, SOL_SOCKET, SO_RCVTIMEO, PAnsiChar(@Opt), OptSize));
{$ELSE}
Check(GetSockOpt(FHandle, SOL_SOCKET, SO_RCVTIMEO, Opt, OptSize));
{$ENDIF}
Result := Opt;
end; function TncLine.GetSendTimeout: Integer;
var
Opt: Cardinal;
OptSize: {$IFDEF MSWINDOWS}Integer{$ELSE}socklen_t{$ENDIF};
begin
OptSize := SizeOf(Opt);
{$IFDEF MSWINDOWS}
Check(GetSockOpt(FHandle, SOL_SOCKET, SO_SNDTIMEO, PAnsiChar(@Opt), OptSize));
{$ELSE}
Check(GetSockOpt(FHandle, SOL_SOCKET, SO_SNDTIMEO, Opt, OptSize));
{$ENDIF}
Result := Opt;
end; Last error is there : procedure ProcessEvent; override; { TConnectThread }
procedure TConnectThread.ProcessEvent;
begin
ConnectResult := Connect(Line.FHandle, Line.AddrResult^.ai_addr^, Line.AddrResult^.ai_addrlen);
end; Seems that this is only for Windows. |
I haven't tested on Android but here are the modifications that work for Windows and Linux (ncLines.pas) function TncLine.GetReceiveTimeout: Integer;
var
Opt: Cardinal;
OptSize: {$IFDEF MSWINDOWS}Integer{$ELSE}socklen_t{$ENDIF};
begin
OptSize := SizeOf(Opt);
{$IFDEF MSWINDOWS}
Check(GetSockOpt(FHandle, SOL_SOCKET, SO_RCVTIMEO, PAnsiChar(@Opt), OptSize));
{$ELSE}
Check(GetSockOpt(FHandle, SOL_SOCKET, SO_RCVTIMEO, Opt, OptSize));
{$ENDIF}
Result := Opt;
end; procedure TncLine.SetReceiveTimeout(const Value: Integer);
var
Opt: Cardinal;
OptSize: Integer;
begin
Opt := Value;
OptSize := SizeOf(Opt);
{$IFDEF MSWINDOWS}
Check(SetSockOpt(FHandle, SOL_SOCKET, SO_RCVTIMEO, PAnsiChar(@Opt), OptSize));
{$ELSE}
Check(SetSockOpt(FHandle, SOL_SOCKET, SO_RCVTIMEO, Opt, OptSize));
{$ENDIF}
end; function TncLine.GetSendTimeout: Integer;
var
Opt: Cardinal;
OptSize: {$IFDEF MSWINDOWS}Integer{$ELSE}socklen_t{$ENDIF};
begin
OptSize := SizeOf(Opt);
{$IFDEF MSWINDOWS}
Check(GetSockOpt(FHandle, SOL_SOCKET, SO_SNDTIMEO, PAnsiChar(@Opt), OptSize));
{$ELSE}
Check(GetSockOpt(FHandle, SOL_SOCKET, SO_SNDTIMEO, Opt, OptSize));
{$ENDIF}
Result := Opt;
end; procedure TncLine.SetSendTimeout(const Value: Integer);
var
Opt: Cardinal;
OptSize: Integer;
begin
Opt := Value;
OptSize := SizeOf(Opt);
{$IFDEF MSWINDOWS}
Check(SetSockOpt(FHandle, SOL_SOCKET, SO_SNDTIMEO, PAnsiChar(@Opt), OptSize));
{$ELSE}
Check(SetSockOpt(FHandle, SOL_SOCKET, SO_SNDTIMEO, Opt, OptSize));
{$ENDIF}
end; {$IFDEF MSWINDOWS}
// Windows-specific types and variables
var
ExtDllHandle: THandle = 0;
procedure AttachAddrInfo;
procedure SafeLoadFrom(aDll: string);
begin
if not Assigned(DllGetAddrInfo) then
begin
ExtDllHandle := SafeLoadLibrary(aDll);
if ExtDllHandle <> 0 then
begin
DllGetAddrInfo := GetProcAddress(ExtDllHandle, 'GetAddrInfoW');
DllFreeAddrInfo := GetProcAddress(ExtDllHandle, 'FreeAddrInfoW');
if not Assigned(DllGetAddrInfo) then
begin
FreeLibrary(ExtDllHandle);
ExtDllHandle := 0;
end;
end;
end;
end;
begin
SafeLoadFrom('ws2_32.dll');
SafeLoadFrom('wship6.dll');
end;
{$ENDIF}
{ TConnectThread }
procedure TConnectThread.ProcessEvent;
begin
{$IFDEF MSWINDOWS}
ConnectResult := Connect(Line.FHandle, Line.AddrResult^.ai_addr^, Line.AddrResult^.ai_addrlen);
{$ELSE}
ConnectResult := Connect(Line.FHandle, Line.AddrResult^.ai_addr^, Line.AddrResult^.ai_addrlen);
{$ENDIF}
end;
initialization
{$IFDEF MSWINDOWS}
var
WSAData: TWSAData;
begin
WSAStartup(MakeWord(2, 2), WSAData);
AttachAddrInfo;
end;
{$ENDIF}
finalization
{$IFDEF MSWINDOWS}
if ExtDllHandle <> 0 then
FreeLibrary(ExtDllHandle);
WSACleanup;
{$ENDIF}
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On android and linux with fmx have this error on 4 part
function TncLine.GetReceiveTimeout: Integer;
var
Opt: DWord;
OptSize: Integer;
begin
OptSize := SizeOf(Opt);
{$IFDEF MSWINDOWS}
Check(GetSockOpt(FHandle, SOL_SOCKET, SO_RCVTIMEO, PAnsiChar(@opt), OptSize));
{$ELSE}
Check(GetSockOpt(FHandle, SOL_SOCKET, SO_RCVTIMEO, Opt, OptSize));
{$ENDIF}
Result := Opt;
end;
Opt:DWord is only windows platform i try with uint32 for other platform but have error on Check(GetSockOpt(FHandle, SOL_SOCKET, SO_RCVTIMEO, Opt, OptSize));
The text was updated successfully, but these errors were encountered: