• 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
Re: Socket timing out
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Socket timing out


  • Subject: Re: Socket timing out
  • From: "Philip D. Wasson" <email@hidden>
  • Date: Fri, 19 Jul 2002 18:19:24 -0400

On Thursday, July 18, 2002, at 04:32 , Aaron Alpher wrote:

I have setup a socket to a printer using socket() then connect() calls. I then send info across the socket using read() and write(). This works well under normal processing, however if I pause the print and do not send data for more than 2 minutes, the socket apparently times out. Is there a way to prevent this? I am setting the SO_KEEPALIVE and the TCP_KEEPALIVE using setsockopt() but my app still crashes after a 2 minute delay in sending. Is there a way to prevent the timeout? Or perhaps a better way to solve this problem?

I wouldn't think that the connection is actually timing out at the TCP level. Perhaps the printer doesn't like a connection to be idle for that long and closes the connection.

IIRC, KEEPALIVE doesn't actually keep anything alive, it just sends tickle packets which will result in an error if the connection is down, so it notices quicker when the connection dies.

As for the crash, it sounds similar to something I asked about a week ago; I was getting a crash when I tried to "send()" on a non-connected socket. Matt Slot helpfully replied:

Your application is probably getting the following signal (from
/usr/include/sys/signal.h):

#define SIGPIPE 13 /* write on a pipe with no one to read it */

Unless you override the default signal handler, this will terminate your
application.

I didn't think of that because it hadn't quite sunk in that I was writing a real Unix application.

So probably you should tell the system to ignore that signal, and try to send _something_ to the printer before 2 minutes elapses. Whether there's anything valid you can send without it really doing anything is another question.

----------------------------------------
Philip D. Wasson
Senior Software Engineer
Managing Editor Inc.
email@hidden
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.

References: 
 >Socket timing out (From: Aaron Alpher <email@hidden>)

  • Prev by Date: Socket timing out
  • Next by Date: Re: bsd sockets & http
  • Previous by thread: Socket timing out
  • Next by thread: BSD port-name versus port-name to give to netstat
  • Index(es):
    • Date
    • Thread