[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.4

pthreads and Sockets -> exits with "Killed"

Asked by darksinclair in C Programming Language

Tags: killed, pthreads, sockets

Greetings, I am trying to create a program which works with both Sockets and pthreads.  The application listens on a specified TCP port and once a request is made it opens up two pthreads, one which parses the incoming data and places the information on a queue, and another that actually processes the information placed on the queue.

My Problem is that once I send data to the socket and the program reads from the socket it crashes with the output "Killed"... I cannot figure out why it is doing this. any ideas?

Here is the output from the program:

$ ./pp
queueInit: Queue Creation Successful.
Socket listening on port '3333'
Server Message: Awaiting socket request.
Server Message: Request acknowledged, processing packet...
Thread [16386] Created.
Thread [32771] Created.
Process Packet Subroutine: Queue EMPTY ... Waiting
Data Received: 192.168.2.11:80:>:192.168.2.1:80:S

Killed
$

As you can see It can open the port fine for listening, accept the data I send in the packet and output the data received ('192.168.2.11:80:>:192.168.2.1:80:S' is the data sent.) and then all of a sudden it simply crashes out with the output Killed.

Below is the relevant code,

//------------------------------------------> main()
...
for( ; ; )
{
     client = sizeof( client_addr );
     printf("Server: Awaiting request.\n");
     newsocket = accept( socket, (struct sockaddr *) &client_addr, &client_socket );
     printf("Server Message: Request acknowledged, processing request.\n");

     pthread_create( &extractor, NULL, extract_info, q );
     pthread_create( &process, NULL, process_packet, q );
     pthread_join( extractor, NULL );
     pthread_join( process, NULL );
}
...

//----------------------------------------->extract_info( void *fifo )
{
     char data[MAX_INPUT_LENGTH];
     input_t *input;
          input = (input_t *) malloc( sizeof( input_t * ) );
     queue *q;
          q = (queue *) fifo;

     printf("Thread [%d] Created.\n", pthread_self() );

     /* Read from the socket - retreive packet information */
     read( newsocket, &data, MAX_INPUT_LENGTH );
     printf("Data Received: %s\n", data );

     printf(" TEST?? " );
...
}

Note : that the program is able to print the Data Received .. Line.. however, it crashes before ever printing the "TEST??" ... As well, if I take out the data received line it does not print the TEST?? line.. it simply crashes out with "killed" again.

Thanks for your time in advance.  Any Comments / Suggestions welcome.
[+][-]09/08/05 09:43 AM, ID: 14846052Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09/08/05 09:45 AM, ID: 14846075Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/08/05 09:47 AM, ID: 14846095Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/08/05 09:55 AM, ID: 14846155Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/08/05 10:03 AM, ID: 14846220Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/08/05 10:08 AM, ID: 14846257Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/08/05 10:29 AM, ID: 14846424Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09/09/05 04:49 AM, ID: 14851363Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: C Programming Language
Tags: killed, pthreads, sockets
Sign Up Now!
Solution Provided By: Infinity08
Participating Experts: 3
Solution Grade: A
 
[+][-]12/20/05 08:30 AM, ID: 15519551Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81