[Cialug] OT: Socket programming + jquery conundrum

Matthew Steven matthew at geniusweb.com
Tue Apr 12 17:44:26 CDT 2011


Sorry for the programming question, but I know at least one or two on 
this list have experience programming with sockets.

I've written a basic HTTP server: bind a listener socket, use accept to 
handle each new connection, read the request (GET ... etc), and then 
send some data back and shut down the socket, return to polling for the 
next one.

As a reference, I have an apache server serving up the same data.

When I use LWP's command line tool "GET" (or GET -e, or nc) the content 
from apache and my own server are identical. My original headers varied 
from the apache headers but for testing purposes I modified them to be 
completely identical.

When I use Firefox to view the page directly, it renders it as proper 
xml and I can view it fine.

But here is the bad part: when pull this data in via jquery (with a 
$.get) there's nothing. If I switch the jquery to pull from the apache 
URL serving the exact same thing, I get all the data listed and it works 
properly.

So that means to me that yes, jquery is part of the problem, but if the 
content being served is identical, I must be doing something with the 
sockets on the server that js/jquery is sensitive to and mozilla itself 
is not. Perhaps I'm not closing a connection the right way?

Also, I am using implicit flushing. I'm delimiting headers from body 
with \r\n\r\n. Pretty sure that Content-length is being calculated properly.

Any thoughts?

If you can reply-all I'll get your answer faster since I'm on the 
digest. Thanks!

-- 
Matthew Steven
http://www.geniusweb.com/
(515) 999 0842



More information about the Cialug mailing list