After a few days of struggling, I got a python codes to work with my hosting account. I am having a bit of trouble running a specific code though (Also I read the TOS and didn't see anything against running a socket server.)
After playing around with the code, I noticed that the print function wasn't working after the line:Code:#!/usr/bin/env python print("Content-type: text/html\n") # TCP server example import socket server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.bind(("", 8000)) server_socket.listen(5) print "TCPServer Waiting for client on port 8000" while 1: client_socket, address = server_socket.accept() print "I got a connection from ", address while 1: data = raw_input ( "SEND( TYPE q or Q to Quit):" ) if (data == 'Q' or data == 'q'): client_socket.send (data) client_socket.close() break; else: client_socket.send(data) data = client_socket.recv(512) if ( data == 'q' or data == 'Q'): client_socket.close() break; else: print "RECIEVED:" , dataI'm obviously a newbie to python, but does this mean I can't bind a port to an ip with this host? Can functions even be disabled in python like php?Code:server_socket.bind(("", 8000))
I appreciate any help.


LinkBack URL
About LinkBacks
Reply With Quote

