📄 discard_worker_threadtype.c
字号:
/* =============================================================================
*
* Description: This is a C implementation for Thread Discard_Worker_ThreadType
*
* -----------------------------------------------------------------------------
* Comments:
*
* ===========================================================================*/
/* Get access to any of the VDK features & datatypes used */
#include "Discard_Worker_ThreadType.h"
#include "charcb.h"
#include "IPv4_util.h"
#include <lwip/sockets.h>
#include <lwip/inet.h>
void
Discard_Worker_ThreadType_RunFunction(void **inPtr)
{
/* Put the thread's "main" Initialization HERE */
charcb_t* p = *(charcb_t**)inPtr;
int r = 1;
while (r > 0)
{
r = recv(p->socket, p->buff, p->buff_len, 0);
VDK_Yield();
}
close(p->socket);
printf("Discard connection from IP %s Port %u - closed\n",
IPv4_straddr(ntohl(p->cliaddr.sin_addr.s_addr)),
ntohs(p->cliaddr.sin_port));
p->socket = -1;
/* Put the thread's exit from "main" HERE */
/* A thread is automatically Destroyed when it exits its run function */
}
int
Discard_Worker_ThreadType_ErrorFunction(void **inPtr)
{
/* TODO - Put this thread's error handling code HERE */
/* The default ErrorHandler kills the thread */
VDK_DestroyThread(VDK_GetThreadID(), false);
return 0;
}
void
Discard_Worker_ThreadType_InitFunction(void **inPtr, VDK_ThreadCreationBlock *pTCB)
{
/* Put code to be executed when this thread has just been created HERE */
/* This routine does NOT run in new thread's context. Any non-static thread
* initialization should be performed at the beginning of "Run()."
*/
}
void
Discard_Worker_ThreadType_DestroyFunction(void **inPtr)
{
/* Put code to be executed when this thread is destroyed HERE */
/* This routine does NOT run in the thread's context. Any VDK API calls
* should be performed at the end of "Run()."
*/
}
/* ========================================================================== */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -