Hi,
I'm playing with SerialIP library and it works fine using Arduino as server (I have successful tested the HelloWorldServer example), but when I try to use Arduino as client it not open the connection.
I'm using the SendEMail example and I'm able to ping Arduino, but it not open any connection (on mail server side I have check with tcpdump)
I have also added some print on smtp_send (note that mail is send via Serial1 of Arduino Mega 2560 board and I use Serial0 as debug)
unsigned char smtp_send(uip_ipaddr_t *smtpserver,
const char *to, const char *from, const char *msg, uint16_t msglen)
{
struct uip_conn *conn;
// Open a connection to the SMTP server on TCP port 25.
conn = uip_connect(smtpserver, HTONS(25));
if (conn == NULL) {
// Too many concurrent outgoing connections. Should never happen
// unless you have multiple connections open at the same time.
debug("Too many c'ns ");
return 0;
}
// If we're here then uip_connect() was able to schedule the connection.
// The actual connect attempt will happen later, and uip_callback will
// be notified when it succeeds.
debug("Connect sched ok");
Serial.println("remote addr");
Serial.println(uip_conn->ripaddr[0],HEX);
Serial.println(uip_conn->ripaddr[1],HEX);
Serial.println("Detected a connection");
Serial.println("local port");
Serial.println(HTONS(uip_conn->lport),DEC);
Serial.println("remote port");
Serial.println(HTONS(uip_conn->rport),DEC);
// Allocate the input buffer, like in the Hello World example.
PSOCK_INIT(&s.psock, s.inputbuffer, sizeof(s.inputbuffer));
// Save the message that we'll send so we can access it later from
// within smtp_thread().
s.to = to;
s.from = from;
s.msg = msg;
s.msglen = msglen;
return 1;
}
and the result is
remote addr
FF
BA80
Detected a connection
local port
82
remote port
32898
The same prints in HelloWorldServer test are correct (remote ip, remote port and local port)
It seems that is try to connect to another ip and port and this explain why I cannot see any connection to the mail server.
Any idea ?
Thank you