这样的代码是什么意思:
int main() {
typedef int UDTSOCKET;
UDTSOCKET recver;
pthread_create(&rsvthread, NULL, recvAndSend, (void *)(unsigned long)recver);
return 0;
}
void* recvAndSend(void* usocket)
{
UDTSOCKET recver = (UDTSOCKET)(unsigned long)usocket;
}
这样的代码对吗?是什么(void *)(unsigned long)recver)
意思,如何unsigned int
转换为void*
,以及如何void*
转换为UDTSOCKET
in
UDTSOCKET recver = (UDTSOCKET)(unsigned long)usocket;
我认为应该是
pthread_create(&rsvthread, NULL, recvAndSend, (void *)((unsigned long*)&recver));
和
void* recvAndSend(void* usocket)
{
UDTSOCKET recver = (UDTSOCKET)(unsigned long)(*usocket);
}
有人可以解释一下吗?