> 1. How do I make the system use my connect() function instead of the
>    glibc's connect(). 

AFAIK, you can't override one function in the library functions. What
you would have to do is to implement the whole library and then link
it in instead of the standard libraries. If you link a library using
-l you are filling up your whole namespace with all the exportable
symbols of that library. So if you link in the system library,
connect(), select(), poll() etc. are all in your namespace. You can't
write a function called connect() and link it as the linker would
complain of duplicate symbols.

> 
> 
> 2. I need to call the glibc's connect() in my connect(). How do i do
> this. (I am trying this by calling __connect and __libc_connect instead in
> my connect and compiling a program with this shared lib. Obviously its not
> working, it seems like I am getting into infinite recursion.)

__connect and __libc_connect are the internal names of this
functions. connect() is most probably just a macro calling
__connect. It is advisable that you don't call __connect as there is
no guarantee that this function would exist in future versions of the
system library. Tomorrow, they might have __connectTCP() instead and
point connect() to this instead. then your program would stop running,
while other programs which called connect() would keep running. This
is probably too far fetched for your current needs. 

Changing system calls in *nix systems is not that simple. Else, we
would have had a profusion of malicious code replacing functions and
taking over the computer( ... now i think i am getting carried away
... i need sleep ;)

-- 
-------------------------------------
Sandip Bhattacharya 
sandipb @ bigfoot.com
http://www.sandipb.net
-------------------------------------

----------------------------------------------
LIH is all for free speech.  But it was created
for a purpose.  Violations of the rules of
this list will result in stern action.

Reply via email to