Hi Mark,
I have a couple of issues with the TCP socket (which I am sure its something I am missing ). I have created a socket as follows and put into listening mode:
USOCKET socket
socket=fnGetTCP_Socket(TOS_MINIMISE_DELAY, (unsigned short)20, fnTCPListener);
fnTCP_Listen(socket, TCP_INPORT, 0);
int fnTCPListener(USOCKET Socket, unsigned char ucEvent, unsigned char *ucIp_Data, unsigned short usPortLen)
{
TCP_MESSAGE test_message;
switch (ucEvent) {
case TCP_EVENT_CONNECTED:
....
break;
case TCP_EVENT_CLOSE:
fnDebugMsg("Port 1919: TCP_EVENT_CLOSE\r\n");
case TCP_EVENT_CONREQ:
case TCP_EVENT_ARP_RESOLUTION_FAILED:
break;
case TCP_EVENT_PARTIAL_ACK: fnSendBufTCP(Socket, 0, usPortLen, TCP_BUF_NEXT);break;
case TCP_EVENT_ACK: fnSendBufTCP(Socket, 0, 0, TCP_BUF_NEXT);break;
case TCP_EVENT_REGENERATE:
break;
case TCP_EVENT_DATA:
...
break;
case TCP_EVENT_ABORT:
case TCP_EVENT_CLOSED:
fnTCP_Listen(Socket, TCP_INPORT, 0); // go back to listening state
fnDebugMsg("Port 1919: Closed\r\n");
break;
}
return APP_ACCEPT;
}
After my windows application connects, and data is sent.
1. If the application doesnt receive info within 5 seconds from the windows application, it is assumed that the connection is lost for some reason, and by doing a fnTCP_close(socket) command the TCP_EVENT_CLOSED command wont be called (as the windows app wont ack the closure). As within the TCP_EVENT_CLOSED command I place it back into fnTCP_Listen() for a normal closure, would I simply put it back into fnTCP_Listen() after I do the fnTCP_close() command ,w ithout worrying that it would cause an issue?
2. I though the command: fnGetTCP_Socket(TOS_MINIMISE_DELAY, (unsigned short)20, fnTCPListener); will have a 20 second timeout if connection has been idle for 20 seconds. The socket times out in 60 seconds instead of 20.
Regards
Neil