I did this test with last CVS HEAD (with a Vista workstation):

static void
tcp_connect_thread(void *arg)
{
int sock;
struct sockaddr_in local;
struct sockaddr_in to;
int iResult;
u32_t server_address;

/* initialize server address */
server_address = inet_addr("192.168.0.1");/*my pc*/
/* if we got a valid server address... */
if (server_address!=0) {
/* create new socket */
sock = socket( AF_INET, SOCK_STREAM, 0);
if (sock>=0) {
/* prepare local address */
memset(&local, 0, sizeof(local));
local.sin_family = AF_INET;
local.sin_port = htons(INADDR_ANY);
local.sin_addr.s_addr = htonl(INADDR_ANY);
/* bind to local address */
if (bind( sock, (struct sockaddr *)&local, sizeof(local))==0) {
/* prepare server address */
memset(&to, 0, sizeof(to));
to.sin_family = AF_INET;
to.sin_port = htons(62345);/* a port which is not opened*/
to.sin_addr.s_addr = server_address;

/* connect to server */
if ((iResult=connect( sock, (struct sockaddr *)&to, sizeof(to)))>=0) {
printf("connected success==%i [%i]\n", iResult, errno);
} else {
printf("connected error==%i [%i]\n", iResult, errno);
}
/* sleep */
sys_msleep(60000);/*let the time to see if any other packet is received*/
printf("close now\n");

}
/* close the socket */
closesocket(sock);
}
}
}

I got :

Starting lwIP, loopback interface IP is 127.0.0.1
Starting lwIP, local interface IP is 192.168.0.2
 0: \Device\NPF_{A6293F5E-B3DF-4E8D-8D01-C65870EEDD1E}
 1: \Device\NPF_{2DA42D7E-7436-40CD-901E-5D73107798B0}
MAC: 00:18:F3:E3:8D:8D
err_tcp==-4
connected error==-1 [0]
close now

-4 = ERR_ABRT

What I can said is the PC never send any RST packet (checked with wireshark). 
Of course, perhaps it's different with another pc OS.

But in all cases, in err_tcp, we set to NULL conn->pcb.tcp. So, we can't reuse 
the pcb. The only solution seems to close the socket and reopen it. If on RST, 
we receive any error, perhaps we could add a line like:
static void

err_tcp(void *arg, err_t err)

{

struct netconn *conn;

conn = arg;

LWIP_ASSERT("conn != NULL", (conn != NULL));

if (conn->pcb.tcp == NULL) return; /*<<<<<<<<<<<<<<<<<<<<<<<<<<*/

conn->pcb.tcp = NULL;

conn->err = err;


----- Original Message ----- 
From: "Jonathan Larmour" <[EMAIL PROTECTED]>
To: "Mailing list for lwIP users" <[email protected]>
Sent: Tuesday, December 11, 2007 11:45 PM
Subject: Re: RE : [lwip-users] Receiving RSTs


> [EMAIL PROTECTED] wrote:
>> Jonathan Larmour wrote:
>> 
>>> I wonder from what Aparna says:
>>>
>>>  
>>>
>>>>>         When the Windows server is not up, the PC responds with a RST
>>>>>         for a received SYN. The connect() API returns an error, and the
>>>>>         client retries connect() after every few seconds.
>>>>>       
>>>
>>>
>>> whether he/she is not closing the socket before calling connect again?
>>>
>>> Maybe the netconn API needs to explicitly disallow connects if 
>>> conn->err is
>>> set?
>>>
>>> Either way, if the socket isn't being closed, Aparna needs to fix 
>>> his/her code.
>>>   
>> 
>> Normally, the socket API allows calling connect for a second time (when 
>> the first call fails and the socket is not already connected).
> 
> Oh yes, of course you are right. Aparna's code should be valid for a BSD 
> sockets API, sorry.
> 
>> LwIP 
>> might not allow this, in which case we can argue if there is 
>> documentation missing or an assert (or a code change)...
> 
> I think in the short term, disallowing based on non-zero conn->err would 
> be best. This could be solved, but probably only when we have the richer 
> set of synchronisation primitives we've been thinking about elsewhere.
> 
> Jifl
> -- 
> eCosCentric Limited      http://www.eCosCentric.com/     The eCos experts
> Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
> Registered in England and Wales: Reg No 4422071.
> ------["The best things in life aren't things."]------      Opinions==mine
> 
> 
> _______________________________________________
> lwip-users mailing list
> [email protected]
> http://lists.nongnu.org/mailman/listinfo/lwip-users
>
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to