I'm currently attempting to connect to a shoutcast server
pull down the information from here and then I'll parse it.
I got this working with the httplib, which was great, the problem is I want to use the select statement to do only do this periodically. (I'm trying to be a client, accepting data, that might be my first problem)
Basically this is the code that im working on to TEST to mimic what the httplib does, only return a socket object making select be able to use.
Event programming is fun :P
anyway here is the code im working on to send a request to the httpserver, bring down the info I want. (parsing and everything I already have control of ;) )
So any advice to fix this would be great :D
Also, if any of you have any advice on event driven socket programming, I'd love to hear it. As you can tell, im fairly new to socket/event programming. Thanks so much guys!
~shonen
pull down the information from here and then I'll parse it.
I got this working with the httplib, which was great, the problem is I want to use the select statement to do only do this periodically. (I'm trying to be a client, accepting data, that might be my first problem)
Basically this is the code that im working on to TEST to mimic what the httplib does, only return a socket object making select be able to use.
Event programming is fun :P
anyway here is the code im working on to send a request to the httpserver, bring down the info I want. (parsing and everything I already have control of ;) )
Code:
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.connect(('ip of the server here', portnum)
if sock.connect:
print "We connected!"
request = """
GET / HTTP/1.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7
Connection: close
"""
sock.send(request)
data = sock.recv(1024)
print data
#####################
output ~> socket.error(104,'Connection reset by peer')
Also, if any of you have any advice on event driven socket programming, I'd love to hear it. As you can tell, im fairly new to socket/event programming. Thanks so much guys!
~shonen