{
Basic object-oriented network functions
- Copyright (C) 2010-2014 MegaBrutal
+ Copyright (C) 2010-2018 MegaBrutal
This unit is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
end;
TTCPListener = class(TThread)
- constructor Create(Port: word; FeatureRequest: word);
+ constructor Create(const Address: string; Port: word; FeatureRequest: word);
{destructor Destroy; override;}
private
FFeatureRequest: word;
+ FListenAddress: string;
FListenPort: word;
FListenSocket: socket;
sAddr: TSockAddr;
end;
-constructor TTCPListener.Create(Port: word; FeatureRequest: word);
+constructor TTCPListener.Create(const Address: string; Port: word; FeatureRequest: word);
begin
+ FListenAddress:= Address;
FListenPort:= Port;
FFeatureRequest:= FeatureRequest;
FreeOnTerminate:= false;
with sAddr do begin
sin_family:= af_inet;
sin_port:= htons(FListenPort);
- sin_addr.s_addr:= 0;
+ sin_addr:= ResolveHost(FListenAddress);
end;
if fpBind(FListenSocket, @sAddr, sizeof(sAddr)) <> -1 then begin
{ It seems the maximum connection value isn't enforced by the
Free Pascal library, so this 512 is a constant, dummy value. }
- { TEMPORARY SETTING OF 1 FROM 512! }
if fpListen(FListenSocket, 512) <> -1 then begin
Result:= true;
Start;