+ Reply to Thread
Results 1 to 4 of 4

Thread: Simple python sockets.

  1. #1
    antidrag is offline x10Hosting Member antidrag is an unknown quantity at this point
    Join Date
    Aug 2008
    Posts
    2

    Simple python sockets.

    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.)
    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:" , data
    After playing around with the code, I noticed that the print function wasn't working after the line:
    Code:
    server_socket.bind(("", 8000))
    I'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?

    I appreciate any help.
    Last edited by antidrag; 05-18-2010 at 10:50 PM.

  2. #2
    Livewire's Avatar
    Livewire is offline Abuse Compliance Officer Livewire is a glorious beacon of lightLivewire is a glorious beacon of light
    Join Date
    Jun 2005
    Location
    Behind a keyboard.
    Posts
    8,998

    Re: Simple python sockets.

    Script Hosting: Space provided by x10Hosting is to be used to create a functional website, we do not allow bots, content scrapers, or any other script that runs continuously on your account. Any scripts that are executed via cron or manually must be directly related to your website.

    ^ There's the part of the TOS that wouldn't work, besides the fact that it is more than likely possible to block functions in python the same as you do in php. In any case, what reason would you have to bind a socket on x10hosting anyways?


    TOS breakers will be suspended regardless of race, creed, national origin, hair color, or favorite food. Thanks for your understanding!

  3. #3
    antidrag is offline x10Hosting Member antidrag is an unknown quantity at this point
    Join Date
    Aug 2008
    Posts
    2

    Why I need a socket server.

    I'm not trying to build anything lowbrow, I'm just trying to make a socket server that can support flash games. I'm developing a multiplayer flash game which needs a socket server for players to connect to each other. There were two other methods I considered:

    #1 Use http polling with a php file
    While this method would work on almost any server. It eats up bandwith and it can only update every 3-5 seconds. Too slow for a live action multiplayer game.
    #2 Use flash's media server
    This method would be best suited for someone who has a lot more money than I do. It costs hundred for anything for anything more than 5 connections at a time. Seems like a nice alternative, but I definitely don't have the money.

    So this would be relevant to the content of the website, since the entire site would be built for this game. Hope this helps clarify what I'm trying to do.

  4. #4
    Livewire's Avatar
    Livewire is offline Abuse Compliance Officer Livewire is a glorious beacon of lightLivewire is a glorious beacon of light
    Join Date
    Jun 2005
    Location
    Behind a keyboard.
    Posts
    8,998

    Re: Simple python sockets.

    It does indeed clarify it, but it also puts it firmly in the realm of "Not on x10hosting" - you need a vps or an actual server for what you're doing, not a website host. X10's part of the TOS where it says this:

    Script Hosting: Space provided by x10Hosting is to be used to create a functional website, we do not allow bots, content scrapers, or any other script that runs continuously on your account. Any scripts that are executed via cron or manually must be directly related to your website.

    Stops yours from working. Your server would have to be continuously running to maintain the bound socket anyways, which is banned explicitly. X10hosting's webservers can't be used for hosting a game server.



    Edit: Quick update too, won't work on paid for a similar reason. The only x10 service it would work on is a VPS, but that does costs $ monthly. It's better than a few hundred, but it's also completely up to you to set it up and admin it; vps's are unmanaged and can be a pain to put it lightly
    Last edited by Livewire; 05-19-2010 at 12:10 PM.


    TOS breakers will be suspended regardless of race, creed, national origin, hair color, or favorite food. Thanks for your understanding!

+ Reply to Thread

Similar Threads

  1. Flash database connection through sockets
    By krahny in forum Programming Help
    Replies: 1
    Last Post: 01-24-2010, 12:00 AM
  2. PHP Sockets
    By Ant59 in forum Free Hosting
    Replies: 2
    Last Post: 04-28-2008, 10:10 AM
  3. I cann't open sockets (:80) Why?
    By uuuuu in forum Free Hosting
    Replies: 1
    Last Post: 12-30-2007, 09:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers