Question

When running the code to connect to Gmail provided by TLama on How to login to a Gmail account and get number of messages in a mailbox with TIdIMAP4? it works wonderfully well in Delphi 5 and Delphi 2007.

I try the same code on Delphi XE3, but strange enough I got 'Socket Error #10061 Connection refused' error when in the IDE or when I launch the exe generated in the \win32\debug directory directly from the file explorer. If I launch the .exe generated in the \Win32\release directory it works correctly!

I tried to put the ssleay32.dll and libeay32.dll in all sort of directories but it still doesn't work and I'm not sure it's related to that.

Indy on Delphi XE3 is version 10.5.9.0. (what originally shipped with my Delphi XE3 Update 1).

Any help greatly appreciated!

Was it helpful?

Solution

Socket error 10061 means one of two things:

  1. you tried to connect to an IP/Port that is not listening for connections at all.

  2. you tried to connect to an IP/Port that is listening for connections, but does not have any available slots to accept new client connections at that particular moment.

There is no way to differentiate between the two possibilities on the client side.

There should be no difference in how Indy manages its sockets in Debug vs Release builds. The issue you are seeing has nothing to do with the DLLs, since they are not invoked until after the underlying socket connection is established first (however, you can use Indy's IdOpenSSLSetLibPath() function in the IdSSLOpenSSLHeaders unit to tell Indy where the DLLs are located, if needed).

Double-check the Port property when calling Connect(). Setting the UseTLS property can actually change the Port value. If you need to set both properties, set UseTLS first, then set Port if you need to use a different value then what Indy assigned.

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