Hopefully fix repeated GET problem

Previously, if we issued http GET more than once every 30 seconds, the second GET would timeout.  It seems this is because the code was using the same fixed port for src and dest - both were 80.  Probably this caused a problem if the second GET happened before the first had closed
This commit is contained in:
mgg1010 2014-05-09 23:44:27 +01:00
parent 967e3da9e0
commit 1b42053c4e

View File

@ -76,7 +76,11 @@ int net_wiznet_createsocket(JsNetwork *net, unsigned long host, unsigned short p
NOT_USED(net);
int sckt = -1;
if (host!=0) { // ------------------------------------------------- host (=client)
sckt = socket(net_wiznet_getFreeSocket(), Sn_MR_TCP, port, 0); // we set nonblocking later
//mgg1010 - added random source port - seems to solve problem of repeated GET failing
sckt = socket(net_wiznet_getFreeSocket(), Sn_MR_TCP, (rand() & 32767) + 2000, 0); // we set nonblocking later
if (sckt<0) return sckt; // error
int res = connect((uint8_t)sckt,(uint8_t*)&host, port);