I use the ethernet example exactly as in the tutorial.
if ((TCP_data_socket = fnGetTCP_Socket(TOS_MINIMISE_DELAY, TCP_DEFAULT_TIMEOUT, fnDataListener)) >= 0) {
fnTCP_Listen(TCP_data_socket, DATA_PORT_NUMBER, 0);
}
static int fnDataListener(USOCKET Socket, unsigned char ucEvent, unsigned char *ucIp_Data, unsigned short usPortLen) {
unsigned char ucTestData[10] = {0,1,2,3,4,5,6,7,8,9};
switch (ucEvent) {
case TCP_EVENT_CONNECTED: // Connection has been established
if (fnSendTCP(TCP_data_socket, ucTestData, 9, TCP_FLAG_PUSH) > 0) {
return APP_SENT_DATA;
}
break;
...
return APP_ACCEPT; //Standard reply which accepts
}
When I call the port with my webbrowser the VS throws an exception
"Run-Time Check Failure #2 - Stack around the variable 'ucTestData' was corrupted.".
When I changed the datatype of ucTestData to unsigned short or int or something, it doesn't crash. But the received data is trash.