title: Intercept a Python server client connection
body: <p>I have programed a simple client server connection that uses TCP to communicate this is the client portion of the code:</p>
  <pre><code>import socket
  import time
  import random
  
  TCP_IP = '127.0.0.1'
  TCP_PORT = 60000
  BUFFER_SIZE = 1024
  Message = [&quot;Password place holder, &quot;, &quot;Testing waiting, &quot;, &quot;There is only Zuul, &quot;, &quot;panic at the disco&quot;]
  
  sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  sock.connect((TCP_IP, TCP_PORT))
  for string in Message:
      sock.send(string)
      value = random.randint(20,40)
      time_end = time.time() + value
      i = 0
      while time.time() &lt; time_end:
          i = i+1
  
  
  data = sock.recv(BUFFER_SIZE)
  sock.close()
  
  print (&quot;recieved data: &quot;, data)
  </code></pre>
  <p>and this the server portion of the code:</p>
  <pre><code>import socket
  
  TCP_IP = '127.0.0.1'
  TCP_PORT = 60000
  BUFFER_SIZE = 1024
  
  sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  sock.bind((TCP_IP, TCP_PORT))
  sock.listen(1)
  
  conn, address = sock.accept()
  print('Connection address: ', address)
  while 1:
      data = conn.recv(BUFFER_SIZE)
      if not data : break 
      print(&quot;Recieved data: &quot;, data)
      conn.send(data)
  conn.close
  </code></pre>
  <p>What I want to know is there a way to design a script that can intercept or read the data being sent between these two programs?</p>