• 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: CFSocket freezes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CFSocket freezes


  • Subject: Re: CFSocket freezes
  • From: Daniel Jalkut <email@hidden>
  • Date: Sun, 27 Nov 2005 19:37:45 -0500

I'm running 10.4.3 and just today I downloaded and compiled the CocoaHTTPServer sample project. I ran it and it works fine. When it launches it prints something along the lines of:

Starting server on port 64942

So, to test it you need to use a URL that explicitly includes that port. By default, the CocoaHTTPServer is reflecting your entire startup disk rooted at "/". So, on my Mac there happens to be a TIFF file at the root of the drive called "printer.tiff", and the following URL works:

http://localhost:64942/printer.tiff

Chilton, when you say it's "not working at all", what do you mean exactly? Doesn't build, doesn't run, runs but errors out, runs but doesn't seem to serve pages? If you run the test project and then telnet to the appropriate port, you should be able to easily confirm whether or not it's "answering the phone":

% telnet localhost 64942
GET /whatever.html HTTP/1.1

Yields:

HTTP/1.1 404 Not Found

Make sure you hit return twice after the "GET" line. Alternately, you can use tcpdump to monitor the loopback activity while you test acessing the server through a web browser:

% sudo tcpdump -Atq -s 0 -i lo0

Interestingly, when I access the CocoaHTTPServer through Safari, I observe that Safari seems to "hang" on the request. That is, even though a "404 not found" message has transmitted across the wire, Safari is not satisfied by the result.

I narrowed this down to the omission of the "Content-Length" header in CocoaHTTPServer's empty error resopnses. For example, I added the following line:

CFHTTPMessageSetHeaderFieldValue(response, (CFStringRef)@"Content- Length", @"0");

In performDefaultRequestHandling, after attaching a 404 error response to the message. This seems to be sufficient to notify the client (Safari) that the message is complete. Otherwise, it would seem that it is waiting for the indeterminately sized message body to come across the pipe.

Could that be related to the problems you folks are seeing?

Another useful tool for these types of situations is "netcat" (nc), which I only discovered recently. You can use this to "be the server" manually from the command line. So, for instance, to debug Safari's reaction to various HTTP server responses, you can do something like this:

% nc -l -p 8675

Now connect to "http://localhost:8675/whatever.html"; from Safari and observe that it is in fact waiting for you to paste or type in a response from the Terminal.

Daniel

On Nov 27, 2005, at 5:42 PM, Chilton Webb wrote:

Hi Uli,

On Nov 27, 2005, at 2:21 PM, Uli Kusterer wrote:
Am 27.11.2005 um 16:15 schrieb Felix Schwarz:
Have you had a look at the CocoaHTTPServer sample code? I had a brief look at it the other day out of interest and could not establish a connection to it, either, although the propagation of the service as such via Bonjour worked for me. This is on 10.4.3 as well. Maybe it's related.
It worked for me. It just has the document root at / and doesn't default to index.htm, so you have to enter a valid document's URL to get a reply.

It's not working here at all. What url should I use to test this?

(10.4.2)

-Chilton
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
sweater.com


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: CFSocket freezes
      • From: Chilton Webb <email@hidden>
References: 
 >CFSocket freezes (From: Frank Illenberger <email@hidden>)
 >Re: CFSocket freezes (From: Felix Schwarz <email@hidden>)
 >Re: CFSocket freezes (From: Uli Kusterer <email@hidden>)
 >Re: CFSocket freezes (From: Chilton Webb <email@hidden>)

  • Prev by Date: Re: CFSocket freezes
  • Next by Date: Re: Is Apple's singleton sample code correct?
  • Previous by thread: Re: CFSocket freezes
  • Next by thread: Re: CFSocket freezes
  • Index(es):
    • Date
    • Thread