Question

I've got a mail server with TIdSMTPServer and TIdPOP3Server that's working fine in lazarus under windows, but if I try to start my program under linux and I try :

SMTPServer.Active := True;
POP3Server.Active := True;

I get this error message : "Could not bind socket. Address and port are already in use." I tried disabling ports 25 and 110 in control center and some commands in the terminal but nothing helped. Can someone give me a hint how to fix this ?

Was it helpful?

Solution

This is a known issue in older Indy 10 releases that was fixed 6 months ago in revision 5066 of Indy's SVN.

If the server's Bindings collection is empty when the server is activated, the Active property setter creates a default IPv4 binding, and a default IPv6 binding if supported by the OS. Both bindings are bound to the same DefaultPort on all local IPv4/IPv6 addresses. Having separate IPv4/IPv6 sockets bound to the same IP:Port works on Windows, it happily manages IPv4 and IPv6 separately, but it does not work on Linux and Android (and probably all other *Nix systems), which is why you get the "already in use" error - the IPv6 binding fails because the IPv4 binding is already using the IP:Port.

To avoid the error, you can either:

  1. upgrade to the latest SVN snapshot, which does not create dual IPv4/IPv6 default bindings on Linux and Android.

  2. make sure the Bindings collection is not empty when you activate the server. Specify your own bindings explicitly as needed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top