Please I try to apply the mechanism Interposition Function in Linux on the function write (write a socket) as follows:
# include <sys/types.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <arpa/inet.h>
# include <netdb.h>
# include <stdio.h>
# include <string.h>
int write (int n, char buffer [32], int sb)
{
int nb = write (so, "Ceci est un exemple de socket!!!", 32);
}
I also have the server code and client code, when the client connects to the server, the server sends a message to the client but when running I got the following error:
write is a system call, and you have write as a local function name. At best this becomes a never-ending recursive call.
Call your function mywrite() or something else, do not name your functions the same thing as syscalls, -read write open and so on.
Interposition is acheived by writing a shared library module (call it mylibrary.so as an example), compling it, then creating a special environment variable, LD_PRELOAD=mylibrary.so, and then running your code. But you still cannot do what your code shows.