Getting incomplete reply from socket

G

Greg Vaughn

I must be missing something. I'm still fairly new to ruby, so I
shouldn't be too surprised. My first real ruby 'project' is to script
telling my wireless router to connect and disconnect the modem. I've
got that part working, but I wanted to add a feature to poll the log of
the router until I actually get connected.

I should mention that this router does not strictly follow the http
spec. In some cases it returns no http header, and when it does, the
content length is usually wrong. These seem to throw the HTTP library
for a loop (curl too), so I dropped down to the socket library for my
work.

When I access the log on the router, here's the type of thing it really
returns (captured via netcat):
HTTP/1.0 200 OK
Pragma: no-cache
Content-Length: 24
Content-Type: application/octet-stream

2003/10/10 20:25:27 Modem starts to dial up to *70,xxx-xxx-xxxx
2003/10/10 20:25:28 Wait for modem's response.
2003/10/10 20:26:37 Since modem has no response. Hang up!
2003/10/10 20:26:42 Modem starts to dial up to *70,xxx-xxx-xxxx
2003/10/10 20:26:43 Wait for modem's response.
2003/10/10 20:27:12 Modem connection baud rate: 48000
2003/10/10 20:27:12 Modem starts PPP.
2003/10/10 20:27:12 Username and Password : OK
2003/10/10 20:27:16 Modem get IP : yy.yy.yy.yy


Here's the ruby I'm using to call it:
def networkSend(tosend)
reply = ""
TCPSocket.open($host, $port) do |aSession|
aSession.send(tosend, 0)
reply = aSession.recv(10000)
end
return reply
end

This is what I get out of ruby (with a trailing blank line):
HTTP/1.0 200 OK
Pragma: no-cache
Content-Length: 24
Content-Type: application/octet-stream


It seems to be missing the body of the message. Does anyone know why?

This happens both on ruby 1.6.7 and 1.8 on Mac OS X.

-Greg Vaughn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top