LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-25-2012, 04:30 AM   #1
chercheur
LQ Newbie
 
Registered: Jun 2012
Posts: 11

Rep: Reputation: Disabled
Function Interposition in Linux


Hello,

Please I try to apply the mechanism Interposition Function in Linux on the function write (write a socket) as follows:
Quote:
# 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:

Erreur de segmentation
Have you an idea please ?

Thank you so much
 
Old 06-26-2012, 12:47 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Just a guess: The string you gave to the function is exactly 32 characters long, in addition with the following zero byte to terminate the string it is 33 characters and doesn't fit into your buffer.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows Spawnl (nowait) like function in Linux... How to use Execl function? cheranj Programming 2 09-15-2011 08:01 PM
library interposition zeegeek Programming 2 10-26-2009 08:30 AM
Compilation issue when Function is parameter in function call on LINUX sa20358 Linux - Software 2 07-24-2008 10:19 PM
Perl exec function in linux (and system-function) nazula Programming 1 04-19-2004 12:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration