A unf. social network done poorly.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.5KB

  1. #! /bin/bash
  2. import socket, threading, time, msvcrt
  3. print "Please enter the following information"
  4. _url = raw_input("URL: ")
  5. _port = raw_input("Port: ")
  6. print "Starting IIM client on port: " + _port
  7. socketOut = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  8. socketOut.connect((_url, int(_port)))
  9. # clear screen here
  10. print "Enter your user details"
  11. _from = raw_input("User id: ")
  12. _to = raw_input("Buddy id: ")
  13. print '\n'
  14. print "Connecting to server..."
  15. print '\n'
  16. # send user details and receive response
  17. socketOut.sendall('@@@'+_from+'##'+_to)
  18. response = socketOut.recv(8192)
  19. def listener():
  20. while 1:
  21. time.sleep(5)
  22. socketOut.sendall('$$$'+_from)
  23. response = socketOut.recv(8192)
  24. if response != " ":
  25. print "\n" + response
  26. if response == 'AUTH_OK':
  27. data = ""
  28. th = threading.Thread(target=listener)
  29. th.setDaemon(1)
  30. th.start()
  31. print "Background polling thread started"
  32. while 1:
  33. if msvcrt.kbhit():
  34. ch = msvcrt.getche()
  35. else:
  36. ch = None
  37. if ch:
  38. if ch != '\r':
  39. data += ch
  40. else:
  41. print '\n'
  42. socketOut.sendall('###'+_from+'##'+data)
  43. response = socketOut.recv(8192)
  44. if response != " ":
  45. print response
  46. data = ""
  47. else:
  48. print "Auhentication failed!"
  49. socketOut.close()