tcp client
i'm using arduino uno , w5100 ethernet shield. i'm trying connect ethernet shield software downloaded ( sockettest v3.00) communication between server (sockettest) , shield (client).the shield jack connected router. created server under ip address of laptop. uses telnet client example can't connect server on sockettest. first time i'm doing tcp/ip , had done similar project or guide me on this.
sockettest -http://sockettest.sourceforge.net/
uno -https://store.arduino.cc/arduino-uno-rev3
ethernet shield -http://www.hobbytronics.co.uk/arduino-wiznet-shield
here code
--------------------
sockettest -http://sockettest.sourceforge.net/
uno -https://store.arduino.cc/arduino-uno-rev3
ethernet shield -http://www.hobbytronics.co.uk/arduino-wiznet-shield
here code
--------------------
code: [select]
#include <spi.h>
#include <ethernet.h>
byte mac[] = {
0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed
};
ipaddress ip(192, 168, 1, 220);// shield ip
ipaddress server(192, 168, 1, 37); // computer ip
ethernetclient client;
void setup() {
// start ethernet connection:
ethernet.begin(mac, ip);// open serial communications , wait port open:
serial.begin(9600);
while (!serial) {
; // wait serial port connect. needed native usb port only
}
// give ethernet shield second initialize:
delay(1000);
serial.println("connecting...");
// if connection, report via serial:
if (client.connect(server, 10002)) {
serial.println("connected");
} else {
// if didn't connection server:
serial.println("connection failed");
}
}
void loop() {
// if there incoming bytes available
// server, read them , print them:
if (client.available()) {
char c = client.read();
serial.print(c);
}
// long there bytes in serial queue,
// read them , send them out socket if it's open:
while (serial.available() > 0) {
char inchar = serial.read();
if (client.connected()) {
client.print(inchar);
}
}
// if server's disconnected, stop client:
if (!client.connected()) {
serial.println();
serial.println("disconnecting.");
client.stop();
// nothing:
while (true);
}
}
i've never used particular piece of software, why trying connect port 10002?
can verify computer listening on port?
pieter
can verify computer listening on port?
pieter
Arduino Forum > Using Arduino > Project Guidance > tcp client
arduino
Comments
Post a Comment