protected
procedure HandleClient(Connection: TTCPConnection); override;
procedure ReceiveEMailData(TCP: TTCPRFCConnection; Response: TRFCReply; SpoolObject: TSpoolObjectCreator);
+ public
+ function StartListen: boolean;
end;
begin
{ Request connection objects with support for RFC-style commands & responses. }
inherited Create(Address, Port, NET_TCP_RFCSUPPORT);
- Logger.AddLine('Server', 'Listening on address: ' + Address + ':' + IntToStr(Port));
end;
+function TMgSMTPListener.StartListen: boolean;
+begin
+ Result:= inherited StartListen;
+ if Result then
+ Logger.AddLine('Server', 'Listening on address: ' + GetSockAddrStr)
+ else
+ Logger.AddLine('Server', 'Failed to listen on address: ' + GetSockAddrStr);
+end;
+
procedure TMgSMTPListener.HandleClient(Connection: TTCPConnection);
{ This is the procedure that actually handles the clients. It receives
an object that manages the established connection in the parameter.
document what bugfix/feature are you testing with the actual build.
This will be logged to help you differentiate outputs of subsequent
builds in your logs. If left empty, it won't be added to the logs. }
- DEVCOMMENT = 'Use getaddrinfo & getnameinfo';
+ DEVCOMMENT = 'Log actual listen address if hostname given';
var
unit Network;
interface
-uses Classes, Sockets, SocketUtils, DNSResolve, NetRFC, Common;
+uses Classes, Sockets, SocketUtils, SysUtils, DNSResolve, NetRFC, Common;
const
TTCPListener = class(TThread)
constructor Create(const Address: string; Port: word; FeatureRequest: word);
{destructor Destroy; override;}
- private
+ protected
FFeatureRequest: word;
FListenAddress: string;
FListenPort: word;
FListenSocket: socket;
SockAddr: TSockAddr;
- protected
procedure HandleClient(Connection: TTCPConnection); virtual; abstract;
procedure Execute; override;
public
+ property ListenAddress: string read FListenAddress;
property ListenPort: word read FListenPort;
+ function GetSockAddrStr: string;
function StartListen: boolean;
procedure StopListen;
end;
end;
+function TTCPListener.GetSockAddrStr: string;
+begin
+ Result:= NetAddrToStr(SockAddr.sin_addr) + ':' + IntToStr(ntohs(SockAddr.sin_port));
+end;
+
function TTCPListener.StartListen: boolean;
var GAIResult: TGAIResult;
begin