Piero 74 wrote:
>I have to develop in my application a task which sends email on certain 
>events. The provide address will be programmed.
>I will use dns to resolve the provider address.
>
>After, i will try to connect to it: if server will be down for some reason, my 
>task will be block forever!!!! 
>
>I need to avoid blocking task... is there a work around?

[Additional information from discussion in lwip-devel: this is using BSD 
sockets.]

The obvious solution would be to create another task to separate the sending of 
e-mail from the normal function of your main task. You can use some kind of 
queue mechanism to copy the e-mail from the main task to the "send e-mail" task.

You may need to limit the queue size to deal with the "mail server offline" 
scenario. The e-mail sending task would discard all pending messages if it 
fails to connect to the server, and then try the connection again the next time 
an e-mail send is requested by the main task.

Depending on memory constraints, you might be able to hold on to old messages 
and try again after a reasonable delay, or perhaps keep a single e-mail message 
which records the fact that you had to delete several due to inability to 
connect to the mail server.

Having a queue for sending multiple e-mail messages also has the advantage that 
you might be able to send several at once in a single connection to the mail 
server, if several notifiable events occur in quick succession.
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to