Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 10th, 2012  |  syntax: Python  |  size: 1.02 KB  |  hits: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #! /usr/bin/env python
  2.  
  3. import random
  4. import sys
  5. import socket
  6.  
  7.  
  8. HOST = ''                 # Symbolic name meaning the local host
  9. PORT = 8001              # Arbitrary non-privileged port
  10. s = None
  11. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  12. while(1):
  13.         s.bind((HOST, PORT))
  14.         s.listen(1)
  15.         conn , adress= s.accept()
  16.         conn.send("welcome to the server\n")
  17.         conn.send("Oh something went wrong with the commandline...\n")
  18.         conn.send("Hope you can solve it anyway!\n")
  19.         conn.send("Type in help for the commands\n")
  20.         conn.send("Gameserver:")
  21.         while(1):
  22.                 data = conn.recv(1024)
  23.                 if data =="help\n":
  24.                         conn.send("login,exit\n")
  25.                         conn.send("Gameserver:")
  26.                 if data == "exit\n":
  27.                         conn.close()
  28.                 if data == "login\n":
  29.                         conn.send("login..\n")
  30.                         conn.send("Gameserver:")
  31.  
  32.         conn.close()