> Well.. the problem is not the "function returns immediatly".. it's just that
> we need UI events to get processed to avoid the windows freezing...
> You also told me on MSN that the host resolving is fast.. yes it IS fast...
> I already tested this, it takes very few milliseconds to get the ip of a
> host.. BUT it is VERY dependant on your connection...
> in other words, if you have a very very slow connection (or a lot of packet
> drops.. since it's UDP), then it will be slow... but most importantly...
> when you have no connection at all, it will completely block until it times
> out (5 or 10 seconds iirc)...

Yes, I agree.

> which means that when you loose your internet connection, and amsn tries to
> auto-reconnect for example, it will freeze for 5-10 seconds completely until
> the dns resolution times out...and that's the real problem...
> In any case, it will be asynchronous since the 'socket' will not 'block', it
> will create a thread, resolve asynchronously, and the 'update' will get you
> back into the Tcl main loop which will continue processing events, this is
> exactly what we need...

Good, then I'm getting my hands on it.

> Anyways, about gethostbyname_r, as I told you before, I wrote some code for
> resolving the hostname in the tcl_farsight extension.. and it is portable to
> windows/mac/etc...
> here's the code :
> static char *host2ip(char *hostname)
> {
>   struct addrinfo * result;
>   static char ip[30];
>   char * ret;
>   int error;
>
>   error = getaddrinfo(hostname, NULL, NULL, &result);
>   if (error != 0) {
>   return NULL;
>   }
>
>   if (result) {
>   ret = inet_ntop (AF_INET,
>   &((struct sockaddr_in *) result->ai_addr)->sin_addr,
>   ip, INET_ADDRSTRLEN);
>   freeaddrinfo (result);
>   if (ret == NULL) {
>   return NULL;
>   }
>   }
>
>   return ip;
> }
>
> Note that the function returns the ip as a string and from a static
> variable, so you don't need to free any allocated memory by the function,
> but calling the function twice will erase the previous value, so once you
> call that, you need to strdup() the string before storing it anywhere... I
> think that if you do a Tcl_NewStringObj(str), it will copy it already
> though...

Nice, I didn't use it previously because I was at work and just made a
quick try.


> ok, we can do it in a much better way.. for example, right now, the code
> looks like this :
> set i 0
> while { 1 } {
>    set subnode [GetXmlNode $xml $path $i]
>    incr i
>    if {$subnode == "" }  { break }
>    ...
> }
> where the GetXmlNode parses from the beginning and compares the index with
> the requested one.. so the first iteration will parse until it finds $path..
> the second iteration will parse until it finds $path, then skip it then
> parse again.. the 100 iteration will reparse the 99 first $path tags that
> were already parsed 99 times before... So maybe we could do something like
> this :
> set subnodes [GetAllXmlNodes $xml $path]
> for {set i 0 } {$i < [llength $subnodes] } { incr i } {
>   set subnode [lindex $subnodes $i]
>   ....
> }

That's exactly what I thought too... I'll take a look.

Greets.


-- 
(:===========================================:)
 Alvaro J. Iradier Muro - [EMAIL PROTECTED]

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Amsn-devel mailing list
Amsn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amsn-devel

Reply via email to