title: Sending text data to remote socket using Arduino Ethernet library
body: <p>I am trying to accomplish something. The thing is, I have an arduino with some sensors, and I want to record their readings from my office and send the data to my computer at home. I used Arduino Ethernet shield to connect the arduino to the internet, and to send data, I used EthernetClient. To receive the data, I used a TCP socket running at address "1111" on my home computer. But when I want to send the data to my home computer, it says that the connection failed.</p>
  
  <p>I have forwarded two ports on my home machine, port 80 and port 1111. When I log onto the home PC using IP Address and port 80 on a browser, it shows me my HTTPD server hosted there. But, when I connect to the same IP Address and port 80 using a Arduino, the connection fails.</p>
  
  <p>Here is my code:</p>
  
  <h1>1. Arduino:</h1>
  
  <pre><code>#include &lt;SPI.h&gt;
  #include &lt;Ethernet.h&gt;
  
  byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
  
  IPAddress server(100, 65, 91, 226); // &lt;&lt;&lt;&lt;&lt;&lt;&lt; My server Address
  IPAddress ip(192, 168, 0, 177);
  
  EthernetClient client;
  
  void setup() {
  Serial.begin(9600);
  while (!Serial);
  
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    Ethernet.begin(mac, ip);
  }
  
  
  delay(1000);
  Serial.println("connecting...");
  
  if (client.connect(server, 1111)) {
    Serial.println("connected");
  } else {
    Serial.println("connection failed");
  }
  }
  
  void loop() {
      client.println("data to be sent");  
  }
  </code></pre>
  
  <h1>2. Python</h1>
  
  <pre><code>import socket
  import time
  
  sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  if not sck:
      print "Could not create a socket for listening on this machine!"
  else:
      print "Successfully created a socket"
  
  sck.bind(("", 1111))
  sck.listen(20)
  
  print "listening to socket 111"
  
  
  def listen():
      while True:
          clientSocket, clientAddr = sck.accept()
          if not clientSocket:
              print "No connection yet!"
              continue
  
          print "connected with", clientAddr
          while True:
              receiv = clientSocket.recv(4096)
              print receiv
              if not receiv:
                  print "Client lost connection!"
                  listen()
  
  listen()
  </code></pre>
  
  <p>I am relatively new to arduino. However, when I try to send data to the python socket using another machine on a different network, it is successful. Arduino just cant seem to connect to the socket. What can I do? 
  Thank you!</p>