我有一个项目,我通过套接字与服务器通信并且运行了很长时间。(下面的源代码......)但是在某些机器上使用丹麦语/中文语言的win 7上它给了我这样的错误:a particular servelet doesn't exist
. 尽管创建了连接并发送了消息,但我收到了错误消息。
现在我想包含winsock2.h
并Ws2_32.lib
想更改MAKEWORD(1,1)
为MAKEWORD(2,2)
. 对于一个长期运行的项目,我在多大程度上可以安全地进行这种更改?
// 我在这里包含了基本的资源。
#include <winsock.h>
// with winsock32.lb
SOCKET sockRef = NULL;
struct sockaddr_in srvInfo;
struct hostent *netHostForName = NULL;
WORD wVersionRequested = MAKEWORD(1,1);
int nRet = WSAStartup(wVersionRequested, &wsaData);
netHostForName = gethostbyname(serverName);
memcpy((char *)&srvInfo.sin_addr, netHostForName->h_addr,
netHostForName->h_length);
srvInfo.sin_port = htons(portNumber);
srvInfo.sin_family = AF_INET;
sockRef = socket(AF_INET, SOCK_STREAM, 0);
connect(sockRef, (struct sockaddr *)&srvInfo,sizeof(srvInfo));
// Sending messages with
SockWrite(Socket, message, strlen(message), 0);
//Receiving messages with
recv(Socket, szBuffer, sizeof(szBuffer), 0);
CLOSESOCKET(Socket);
WSACleanup();