title: Sending data over TCP from arduino to python
body: <p>I've been struggling with this for a few hours now and really just don't know where to go from here.  I've got an arduino uno with a wifi shield connected to a network, and a laptop with Ubuntu connected to the same network.  I'm using the arduino <a href="http://arduino.cc/en/Reference/WiFi" rel="nofollow">Wifi Library</a> to connect to the network.</p>
  
  <p>I can send data to my laptop from the arduino and print it successfully using: <code>sudo nc -l 25565</code></p>
  
  <p>I am also trying to use the following python code to do the same thing I did with <code>nc</code> which is also being run as <code>sudo</code> just in case:</p>
  
  <pre><code>#!/usr/bin/env python
  
  import socket
  
  TCP_IP = '127.0.0.1'
  TCP_PORT = 25565
  BUFFER_SIZE = 1024
  
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.bind((TCP_IP,TCP_PORT))
  s.listen(1)
  
  (conn,addr) = s.accept()
  print 'Connection address: ',addr
  while True:
      data = conn.recv(BUFFER_SIZE)
      if not data: break
      print 'received data: ',data
      conn.send('ECHO')
  conn.close()
  s.close()
  </code></pre>
  
  <p>But it just hangs at <code>(conn,addr) = s.accept()</code>.  Using a client python script on the same laptop I can connect to the above server and I can send data to it which the server then prints.</p>
  
  <p>I just have no idea why <code>nc</code> will print from the arduino but the python server script won't, even though it will print from a python client.  Could the arduino libraries be failing to follow some standard that python expects?  Thanks in advance.</p>