Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6628041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:05:05+00:00 2026-05-25T22:05:05+00:00

I have create a pthread_create inside a pthread_create, I have used socket programming, where

  • 0

I have create a pthread_create inside a pthread_create, I have used socket programming, where I receive a packet and then create a thread which does the writing to the file. When I send a very large file, i get this error…??

The code is as follows…

void *writePack(void *sock)
{

    size_t nbyte;
    ssize_t writeSize;
    nbyte = 1466;
    off_t offset;
    offset = (((struct writePacket *)sock)->seq * 1466);
    char* buffer = new char();
    buffer = ((struct writePacket *)sock)->datamsg;
    writeSize = pwrite(((struct writePacket *)sock)->pp,(const void *)buffer, nbyte, offset );
    free(buffer);
    pthread_exit(NULL);
}

this is the code of the parent receive code…

recvfrom(sockA->sockid, (void *)&recvdata, sizeof(struct data), 0, (struct sockaddr *) &cli_addr, &clilen);
        if (n<0)
            error("Error on reading");

        pthread_mutex_lock(&qlock);
                struct writePacket* a;
        a=new writePacket;
        a->sockID = sockA->sockid;
        a->pp = sockA->pp;
        a->seq = recvdata.seq;
        memcpy(a->datamsg,recvdata.datamsg,1466);

        pc = pthread_create(&write[counter], NULL, writePack,(void *) a);
                     if (pc)
                        {
                           printf("ERROR; return code from pthread_create() is %d\n", pc);
                             exit(-1);
                        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:05:06+00:00Added an answer on May 25, 2026 at 10:05 pm

    It could be that the threads you create didn’t get a chance to execute, while you’ve been creating more and more threads reading from the socket.

    Instead, create a thread that would do the reading from the socket, another thread that would do the writing, and pass the data in messages between the two threads.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have started new thread with pthread_create() and then detached it using
pthread_create(&thread, NULL, AcceptLoop, (void *)this); I have declared like this and inside of the
I am programming with C and pthreads. I have a long running function which
Will I run into an error if I create a pthread_create inside a pthread,
I have called a method using a secondary thread. From inside the method i
I have create my own NSOpenGLView class, right now the data that i want
I have create name range on sheet A so I need to use this
i have create a form (so it's PHP and HTML hybrid-code). it has ability
I use TcxGrid I have create fields on execution time because I have a
This is what I currently have: CREATE OR REPLACE TRIGGER MYTRIGGER AFTER INSERT ON

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.