[maemo-developers] [maemo-developers] "Smartest" way to start network connection "before" socket connection is attempted to be made

From: Tomi Ollila tomi.ollila at guru.guru-group.fi
Date: Sat Mar 4 10:42:20 EET 2006
Tomi Ollila <tomi.ollila at guru.guru-group.fi> writes:

> Hi
>
>
> In a program I need to know the IP of the interface before doing
> any network connections. 
>
> So far the program has complained 'Please start network connection first'
>
>
> But I'd like to have smarter solution, like do the automatic network
> connection that LD_PRELOAD -trick does but not to connect anywhere.
>
> Does anyone know a good way to achieve this, so that the network connection
> stays alive and closes on request, or when the program exits (unless there
> is someone else using the connection...).

I'm "answering" to my own mail...

I found the following explanation from
http://www.gossamer-threads.com/lists/maemo/developers/4292?page=last
(google search LD_PRELOAD maemo)

   "For test purposes, try running socket() call before gethostbyname().
    The IC preload library wraps socket() and close() functions, but
    gethostbyname() should call socket(). For some reason it's not
    happening now." 

by Kalle Valo at nokia... hmm, Feb 6, 2006 on this list so I've been
missing important discussion while being subscribed on this list... 
well, that just shows how hard it is to find suitable information from
Internet on these issues... (Same applies to that StartupVMClass I asked
earlyer -- it is documented in maemo tutorial but how could one remember
that -- a template/example .desktop file with all included (and commented) 
would be nice !!!).

Here it is interesting that socket() is wrapped, I would have quessed
that connect()/sendto() were wrapped; If I'm connecting to 127.0.0.1 why
open network connection... Or is there some deeper "trickery" involved
(I sure hope not, as that would make it too unpredictable for application
programmers).

Anyway, I'm testing that by just opening one socket and keep that open
until all done...

> Tomi


Tomi

More information about the maemo-developers mailing list