🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
7 messages
7 total messages Started by Lapo Guidi Sun, 13 Nov 2005 02:12
TIdPOP3 connection problems
#3163
Author: Lapo Guidi
Date: Sun, 13 Nov 2005 02:12
50 lines
2079 bytes
Hi all,
I have a problem when TIdPOP3 component try to connect to a host while 
internet or lan connection are not alive.
I have a simple TThread descendant that check for new messages and all is 
working fine when connectivity is present.
The code inside the Execute of the thread is:

void __fastcall TService::Execute(void)
{
  TIdPOP3 *POP3=new TIdPOP3(NULL);
  try {
    POP3->Host="mailserverhost";
    POP3->Port=110;
    POP3->Username="username";
    POP3->Password="password";
    try {
      POP3->Connect();
      int MsgCount=POP3->CheckMessages();
      if(MsgCount>0) {
        for(int i=1;i<=MsgCount;i++) {
          TIdMessage *Msg=new TIdMessage(NULL);
          try {
            POP3->Retrieve(i, Msg);
            // snipped store procedure
          }
          catch(Exception &e) {
            // Reading error
          }
          POP3->Delete(i);
          delete Msg;
        }
      }
      POP3->Disconnect();
    }
    catch(Exception &e) {
      // Connection error
    }
  }
  __finally {
    delete POP3;
  }
}

I made some errors using these components?
Should I set ReadTimeout property or something similar?
I thought to do Connect(int Timeout) but it doesn't exists.

Any help appreciate.

Lapo 
Re: TIdPOP3 connection problems
#3164
Author: Remy Lebeau (TeamB)
Date: Sun, 13 Nov 2005 08:02
11 lines
1212 bytes
"Lapo Guidi" <lapoguidi@inwind.it> wrote in message 
news:4376a0e1@newsgroups.borland.com...

> I have a problem when TIdPOP3 component try to
> connect to a host while internet or lan connection are not alive.

What EXACTLY are you having a problem with?  Please be more specific.


Gambit 
Re: TIdPOP3 connection problems
#3165
Author: Lapo Guidi
Date: Sun, 13 Nov 2005 09:53
5 lines
1143 bytes
Ops, I forgot to mention the problem, I'm sorry.
The problem is that the thread freeze for a great amount of time when 
network connection is not alive.

Lapo 
Re: TIdPOP3 connection problems
#3166
Author: Remy Lebeau (TeamB)
Date: Sun, 13 Nov 2005 10:05
19 lines
1698 bytes
"Lapo Guidi" <lapoguidi@inwind.it> wrote in message 
news:43770cf1$1@newsgroups.borland.com...

> The problem is that the thread freeze for a
> great amount of time when network connection
> is not alive.

That is to be expected.  Indy is a blocking library, and you did not specify 
any timeout for the Connect().  If the OS does not know that the network is 
not available then sockets will not know either, and thus it could take 
awhile for any errors to be reported.

You did not say which version of Indy you are using.  Connect() in Indy 9 
does have an ATimeout parameter.  In Indy 10, the parameter has been 
replaced with a ConnectTimeout property instead.


Gambit 
Re: TIdPOP3 connection problems
#3167
Author: Lapo Guidi
Date: Sun, 13 Nov 2005 10:37
8 lines
1205 bytes
Thanks Remy, I forgot to enter the ATimeout on the Connect() method.
I copied the source from another post and I adapted it to my needs, but I 
don't see that missed parameter.
I use Indy v9.0.14.

Thanks very much.

Lapo 
Re: TIdPOP3 connection problems
#3168
Author: Remy Lebeau (TeamB)
Date: Sun, 13 Nov 2005 23:38
10 lines
1403 bytes
"Lapo Guidi" <lapoguidi@inwind.it> wrote in message 
news:43771721@newsgroups.borland.com...

> I use Indy v9.0.14.

That is an old build.  The current snapshot build is 9.0.50.


Gambit 
Re: TIdPOP3 connection problems
#3169
Author: Lapo Guidi
Date: Mon, 14 Nov 2005 01:04
3 lines
1218 bytes
I downloaded it, thanks.

Lapo 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads