X-Git-Url: http://git.megabrutal.com/?p=mgsmtp.git;a=blobdiff_plain;f=Network.pas;fp=Network.pas;h=10a95f991d3898060489ecfdc31d252c242b81d7;hp=5ef26164939b85795cf4abc85ef5cf93d20ba9f4;hb=f70bfb8a7f2c72758be721b78a7e9f33321dca21;hpb=a24c25ac25193f6cc296af1765fa25b68aa8525f diff --git a/Network.pas b/Network.pas index 5ef2616..10a95f9 100644 --- a/Network.pas +++ b/Network.pas @@ -1,6 +1,6 @@ { 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 @@ -99,10 +99,11 @@ type 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; @@ -163,8 +164,9 @@ begin 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; @@ -292,12 +294,11 @@ begin 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;