Hi Mark,
I think I must be doing something wrong, but not sure what.
After a connection is made to socket, my windows application sends down about 270 bytes of data, which is read, and an "ACK" (this is an ascii "ACK" sent as a string) is sent back from 52235. If the windows app receives an "ACK" then the procedure continues, until all data is sent, which works perfect. After this , or anytime I attempt to close the connection from Windows with the following:
shutdown(socket,SD_BOTH);
closesocket(socket);
The TCP_EVENT_CLOSED never gets called, or never times out, even when closing the Windows application.
Here is the callback routine:
int fnTCPListener(USOCKET Socket, unsigned char ucEvent, unsigned char *ucIp_Data, unsigned short usPortLen)
{
TCP_MESSAGE test_message;
unsigned char Value;
int Loop;
switch (ucEvent) {
case TCP_EVENT_CONNECTED:
SendToUser((unsigned char *)"\r\nCONNECTED\r\n",strlen("\r\nCONNECTED\r\n")); //message sent through serial
case TCP_EVENT_CONREQ:
case TCP_EVENT_CLOSE:
case TCP_EVENT_ACK:
case TCP_EVENT_ARP_RESOLUTION_FAILED:
case TCP_EVENT_PARTIAL_ACK:
break;
case TCP_EVENT_REGENERATE:
break;
case TCP_EVENT_DATA:
for(Loop=0;Loop<usPortLen;Loop++)
{
Value=ucIp_Data[Loop];
if(!ReadInBlock(&TCBrxBuff,Value)) //simply reads into own buffer, and checks to see if all read..
{ //Yip all read in , now proceed with command request...
RxBuff=&TCPrxBuff;//point to structure being processed
ProcessCommand(); //process command..
}
}
break;
case TCP_EVENT_ABORT:
case TCP_EVENT_CLOSED:
fnTCP_Listen(Socket, TCP_INPORT, 0); // go back to listening state
SendToUser((unsigned char *)"\r\nCLOSED\r\n",strlen("\r\nCLOSED\r\n"));
break;
}
return APP_ACCEPT;
}
void ProcessCommand(void)
{
//command carried out here.. ie saved into spi eeprom
TCP_MESSAGE test_message;
strcpy(test_message.ucTCP_Message,"ACK");
fnSendTCP(Test_socket, (unsigned char *)&test_message.TCP_Header, 3, TCP_FLAG_PUSH);
}
But cant close connection..
Regards
Neil