SOCKERR_TIMEOUT after calling connect()


#1

I am having trouble connecting a W5500 to a HTTP file server. The server runs fine if I use my PC to connect. But with W5500, connect() call always results with SOCKERR_TIMEOUT. Can someone look the Wireshark capture and tell me if the SYN packet from W5500 looks OK? Thanks.http_file_server_connect.zip (1.6 KB)


#2

I need to call setSn_PORT() to set my source port. Otherwise I think W5500 will use the same destination port number as the source port.


#3

Correct. By default it is 0. You set it to 80. Web server does not want to respond to port 80. Set the source port in range of 0xc000-0xfffe, and make the port number dynamic - so that for every new connection to this web server’s port 80 you use previous port number + 1.


#4

Thanks for the comment.

What is still a bit of puzzling is that I made this mistake a few months ago by passing in port number 80, instead of 0, when calling socket() API for a HTTP client socket. This bug wasn’t discovered sooner because everything seemed to be working just fine in the office. However, when I took the device home and plugged it into my Google WiFi router, I couldn’t connect, as if either the SYN never reached the server or the SYN ACK was lost. Any theory why it was mistakenly working?