Connect() fails using Ethernet Board + Ethernet Library


using arduino sketch below, in arduino ethernet rev 3 board, see blinks of arduino tx/rx leds connection attempts, connection attempts never succeed.  see blinking @ (desktop) network switch.

the "server" code python routine able accept connections different python routine (both in same windows computer) wrote testing sort of thing.  have posted snippets of python routine.

this has got simple; stumped.  have searched web similar problems; , have searched first 15 pages of site's "networking, protocols , devices" history, no avail.

hopefully spot problem, or remember how solved similar one, or offer checklist of things me double check.

here arduino "client" code.
code: [select]

#include <spi.h>

#include <dhcp.h>
#include <dns.h>
#include <ethernet.h>
#include <ethernetclient.h>
#include <ethernetserver.h>
#include <ethernetudp.h>
#include <util.h>


void setup()
   {
   // put setup code here, run once:
   // ------------------- ethernet setup section ---------------------------//
   byte mymac[] = { 0x90, 0xa2, 0xda, 0x0d, 0xb7, 0xe6 };
   byte myip[] = { 192, 168, 0, 10 };
   byte dns[] = { 192, 168, 0, 1 };
   byte gateway[] = { 192, 168, 0, 1 };
   byte mysubnet[] = { 255, 255, 255, 0 };
   byte serversip[] = { 192, 168, 0, 2 };
   int serversport = 14531;
   ethernetclient client;

   serial.begin(9600);
   
   delay(1000);
   serial.println("5");
   delay(1000);
   serial.println("4");
   delay(1000);
   serial.println("3");
   delay(1000);
   serial.println("2");
   delay(1000);
   serial.println("1");
   delay(1000);
   serial.println("0");
   
   ethernet.begin(mymac, myip);
//   ethernet.begin(mymac, myip, dns, gateway, mysubnet);
   delay(1000);
   serial.print ("my ip = ");      serial.println (ethernet.localip());
   serial.print("connecting port "); serial.print(serversport);
   serial.print(" @ "); serial.print(serversip[0]);
   serial.print("."); serial.print(serversip[1]);
   serial.print("."); serial.print(serversip[2]);
   serial.print("."); serial.print(serversip[3]);
   serial.println("...");
   
//   client.connect(serverip, serversport);
   if (client.connect(serversip, serversport))
      {
      serial.println("connected");
      }
   else
      {
      serial.println("connection failed");
      }

   }

void loop()
   {
   // put main code here, run repeatedly:
   }


here snippets of "server" python code:
code: [select]

...
addressfamily = af_inet
connectiontype = sock_stream
clientaddress = '192.168.0.2'
serveraddress = '192.168.0.2'
...
serversacceptport = 14531
serversacceptnodeinfo = (serveraddress, serversacceptport)
talktoserversocket = none
...
mysvrsock.bind(self.serversacceptnodeinfo)
serveraccepttimeout =10.0                         
mysvrsock.settimeout(serveraccepttimeout)
mysvrsock.listen(0)
...
talktoclientsocket, talktoclientnodeinfo = mysvrsock.accept()
...


any thoughts?

gblaker

did allow tcp port 14531 through windows firewall?


Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > Connect() fails using Ethernet Board + Ethernet Library


arduino

Comments

Popular posts from this blog

Convierte tu Raspberry en un NAS. Firmware fvdw-sl 15.3 - Raspberry Pi Forums

How to format a Get Request

avrdude: verification error, first mismatch at byte 0x0000 0x0c != 0x62