我只是使用C编程的初学者.对于我的大学项目,我想创建一个多线程服务器应用程序,多个客户端可以连接并传输可以保存在数据库中的数据.
经过许多教程后,我对如何使用pthread_create创建多个线程感到困惑.
它在某处完成了:
pthread_t thr;
pthread_create( &thr, NULL , connection_handler , (void*)&conn_desc);
Run Code Online (Sandbox Code Playgroud)
它就像是某个地方
pthread_t thr[10];
pthread_create( thr[i++], NULL , connection_handler , (void*)&conn_desc);
Run Code Online (Sandbox Code Playgroud)
我尝试在我的应用程序中实现这两个,似乎工作正常.上述两种方法的哪种方法是正确的,我应该遵循.对不起英语和描述不好.
htons() 将主机字节顺序转换为网络字节顺序.
网络字节顺序是Big-Endian,主机字节顺序可以是Little-Endian或Big-Endian.
在Little Endian系统上,htons()将多字节变量的顺序转换为Big-Endian.htons()如果主机字节顺序也是Big-Endian,会怎么做?