Advertisement
Guest User

Network Programming

a guest
Mar 19th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. """
  2. Given Tasks:
  3. I.) Connects to a network service
  4. II.) Asks for version information
  5. III.) Receives the response
  6. IV.) Disconnects
  7. V.) Prints the response.
  8. """
  9. #________________________________________________________Script____________________________
  10. print("\n\n")
  11.  
  12. import socket
  13.  
  14. def main():
  15.     host = '##.###.##.###'
  16.     port = ####
  17.  
  18.     s = socket.socket()
  19.     s.connect((host, port))
  20.  
  21.     data = s.recv(1024)
  22.     print('Received from server: ' + str(data))
  23.     print('\n')
  24.     message = input("String Code: ")
  25.     s.send(b'message')
  26.     data = s.recv(1024)
  27.     print('Received from server: ' + str(data))
  28.     s.close()
  29.  
  30. if __name__ == '__main__':
  31.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement