Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. import socket
  2.  
  3. def CallAPI(data):
  4. try:
  5. client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  6. client.connect(('0.0.0.0', 9876))
  7.  
  8. client.send(data)
  9. response = client.recv(4096)
  10. client.close()
  11.  
  12. except Exception as e:
  13. print e
  14.  
  15. finally:
  16. client.close()
  17.  
  18. return response
  19.  
  20. response = CallAPI("hello world")
  21. print response
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement