Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 May : IdFTP (10.1.5) Where is my local port number?
| Subject: | IdFTP (10.1.5) Where is my local port number? |
| Posted by: | "Marc Wetzel" (mwnospamse@gmx.de) |
| Date: | Tue, 15 May 2007 19:09:40 |
Hi,
In my software I need to know the local port number, after I connected to a
ftp-server (for the control and for the data connection), to configure a
tcp-sniffer, which is running in another thread.
Where can I find the numbers?
After several hours of debugging, I found a number, which is relatively near to
the number I'm looking for, but its always off by 2.
Currently I'm trying with the following code:
FTP := TIdFTP.Create(Self);
try
// [...] some more settings, e.g. username/pwd
FTP.IOHandler := IdIOHandler; // <- this is a IdIOHandlerStack
FTP.Connect;
Log(Format('Local port opened: Peer: %d, Port: %d',[
IdIOHandler.Binding.PeerPort, IdIOHandler.Binding.Port]));
finally
FTP.Disconnect;
FTP.Free;
end;
This is the Log of the above code:
15.05.2007 18:53:54.343 IOHandler Status Connecting to [IP-Adress ommitted].
15.05.2007 18:53:54.343 Connected.
15.05.2007 18:53:54.375 FTPBannerBeforeLogin 220 ProFTPD 1.2.10 Server
15.05.2007 18:53:54.437 FTPBannerAfterLogin 230 User test logged in.
15.05.2007 18:53:54.468 FTPAfterClientLogin
15.05.2007 18:53:54.484 Connection established
** 15.05.2007 18:53:54.484 Local port opened: Peer: 21, Port: 2220
15.05.2007 18:53:54.500 Disconnecting.
15.05.2007 18:53:54.500 FTPDisconnected
15.05.2007 18:53:54.500 Disconnected.
Wireshark shows me that in reality we were connected with
port-pair: 2222 -> 21
Transmission Control Protocol
Source port: 2222 (2222)
Destination port: ftp (21)
Sequence number: 4015518599
What is going wrong here?
By the way, I'm using the stock Indy V10 that comes with Delphi 2007.
I also tried with Indy9 (in Delphi 2006)
TIA
Marc