我已经创建了一个应用程序,其中我想要一个线程来单独处理listen-UDP并使我成为一个缓冲区,但是当我尝试将它传递给线程时它表示存在兼容性问题
hThread = CreateThread(
NULL, // default security attributes
0, // use default stack size
start, // thread function name
&buffer, // argument to thread function
0, // use default creation flags
&dwThreadId);
我的开始功能是
void start(buffer_t *buffer)
{
SOCKET s;
struct sockaddr_in server, si_other;
int slen , recv_len;
char buf[BUFLEN];
WSADATA wsa;
}
,错误是
1 IntelliSense:类型" void(*)(buffer_t * buffer)"与#34; LPTHREAD_START_ROUTINE"类型的参数不兼容c:\ users \ madihamalik \ documents \ visual studio 2010 \ projects \ udp listener \ udp listener \ listerner.c 189 12 UDP侦听器
答案 0 :(得分:2)
尝试以下可能对您有用的代码..
DWORD start(LPVOID lpdwThreadParam)
{
buffer_t *buffer = (buffer_t *)lpdwThreadParam; //Type cast your argument here
SOCKET s;
struct sockaddr_in server, si_other;
int slen, recv_len;
char buf[BUFLEN];
WSADATA wsa;
...
}