• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Socket lockup when mac put to sleep and woken up
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Socket lockup when mac put to sleep and woken up


  • Subject: Socket lockup when mac put to sleep and woken up
  • From: Arjun SM <email@hidden>
  • Date: Wed, 20 Feb 2013 00:10:27 +0530

 Hi all,

I have implemented a daemon which tries to make a connection to a server using non-blocking sockets and works fine. But the problem surfaces, when I put my Mac machine to sleep for few hours and wake it up. My daemon hangs and i get a SIGPIPE on the error console after some time.
I am running Mountain Lion OS X 10.8.2 version.

The MakeConnect() function which I am using in my daemon is fairly simple and below is an excerpt,
 m_AgencySock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

set the socket to non-Blocking
int err = fcntl(m_AgencySock, F_SETFL, O_NONBLOCK);

int status = connect(m_AgencySock, (struct sockaddr *)&m_AgencyAddress, sizeof(m_AgencyAddress));
    if (status < 0)
    {
        status = errno;  // Check the error number to get our current status
        if (status == EINPROGRESS)
       {
           FD_ZERO(&readFDs);
            FD_ZERO(&writeFDs);
            FD_SET(m_AgencySock, &readFDs);
            FD_SET(m_AgencySock, &writeFDs);

            Call select with struct timeval waitd in a while loop and check for selectResult > 0 and break;
         waitd.tv_sec = 10;
         waitd.tv_usec = 0;
         selectResult = select(m_AgencySock + 1, &readFDs, &writeFDs, NULL, &waitd);

       }
}

I am resetting the struct timeval waitd before calling select() again.

is there any other parameters that needs to addressed?

thanks in advance,
~Arjun

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Socket lockup when mac put to sleep and woken up
      • From: Josh Graessley <email@hidden>
  • Prev by Date: Re: arp spoofing
  • Next by Date: Re: Socket lockup when mac put to sleep and woken up
  • Previous by thread: Re: arp spoofing
  • Next by thread: Re: Socket lockup when mac put to sleep and woken up
  • Index(es):
    • Date
    • Thread