Hello all. I've previously created a working socket program in C in a 32-bit machine and now I have to transfer it to a 64-bit machine. May I ask if there is anything I have to change in my program to make it work in a 64-bit machine? I did some research on how to do it and from what I've learned, it seems like I'll have no problem transferring the program and make it work except for one function I used. I used htons in my program in the 32-bit machine and it seems that it has a 64-bit counterpart. (Whatever the counterpart is, it wasn't mentioned in the tutorial I read.) I will transfer the program soon so I need to know the changes I have to make (if there is any). Answers will be greatly appreciated. Thanks!
Here is the socket programming part of my code (it's a Windows version but is very similar to a Linux version) Can anyone tell me which part I need to change for it to suit in a 64-bit machine?
SOCKADDR_IN servaddr;
ZeroMemory(&servaddr, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(80);
servaddr.sin_addr.s_addr = inet_addr("192.168.30.1");
ConnectSocket = socket(PF_INET, SOCK_STREAM, 0);
if (ConnectSocket == INVALID_SOCKET) {
printf("socket failed with error: %ld\n", WSAGetLastError());
WSACleanup();
system("PAUSE");
return 1;
}
iResult = connect(ConnectSocket, (LPSOCKADDR)&servaddr, sizeof(struct sockaddr));
if (iResult == SOCKET_ERROR) {
closesocket(*ConnectSocket);
ConnectSocket = INVALID_SOCKET;
return;
}