From: Osuka Adartse Date: 2003-12-02T04:40:02+09:00 Subject: Re: Reading a returned code from socket and httpq Osuka Adartse wrote: > I have a question regarding sockets, I'm trying to use the HttpQ plugin > so open a socket to host x at 4800 plus passwd, and send commands, so > far so good(commands working), but I'm having trouble figuring how to > read the returned code. > > All I keep getting is:"HTTP/1.0 200 OK\r\nServer: Winamp httpQ Plugin > Version 2.1\r\nContent-Type: text/html\r\n\r\n" if I use Net::HTTP.new, I get the same so Net::HTTP.newobj is > at the end of this string there should be a return code like: > > " 1" or " 5353. Singyguy - sillysong" > > but there's nothing, so anybody have an idea how to do this? > Thanks emmanuel (why directly thought?) you put me on the right track I should have used Net:HTTP like: require "Net/http" Net::HTTP.version_1_2 val=Net::HTTP.newobj("localhost","4800") val.start p val.get("/PLAY?p=passw") #=>[#, "1"] #starts playing song p val.get("/GETCURRENTTITLE?p=passwd") #=>[#, "2499. Carmina Burana - O Fortuna"] #gets the song data Now not only works, but also gives me the needed response! And thanks to the stdlib project, help me quite a bit in http.rb: Documented by Minero Aoki; converted to RDoc by William Webber. so thanks Minero Aoki and Mr. Webber