Originally posted by: Ricardo Matos
#pragma comment(lib, "ws2_32.lib")
no further questions...
Hi, i have the file ws2_32.dll in the path C:\WINNT\system32 the question is, should i copy it to another path? The file ws2_32.lib is in the path C:\Programas\Microsoft Visual Studio\VC98\Lib is it also correct? I am working with Visual Studio C++ 6.0. The error tha i experienced is "#error WINDOWS.H already included. MFC apps must not #include <windows.h>" in the file afxv_w32.h, do you have any idea of wath am i doing wrong? Once i didnt know where to put the following code i put it in all .h files -->
#include<winsock2.h>
#include<stdafx.h>
My best regards to everibody
Ricardo Matos
Originally posted by: d.saisyam
This code is very good
Originally posted by: Michael B. Pliam
I have tried to compile this code using VCPP 6.0 in a console app, including <afx.h> and the lib and dlls as specified. The code compiles but the following linker errors are encountered:
InetFunc.obj : error LNK2001: unresolved external symbol __imp__gethostbyaddr@12
InetFunc.obj : error LNK2001: unresolved external symbol __imp__inet_addr@4
InetFunc.obj : error LNK2001: unresolved external symbol __imp__inet_ntoa@4
InetFunc.obj : error LNK2001: unresolved external symbol __imp__gethostbyname@4
InetFunc.obj : error LNK2001: unresolved external symbol __imp__closesocket@4
InetFunc.obj : error LNK2001: unresolved external symbol __imp__recvfrom@24
InetFunc.obj : error LNK2001: unresolved external symbol __imp__sendto@24
InetFunc.obj : error LNK2001: unresolved external symbol __imp__setsockopt@20
InetFunc.obj : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
InetFunc.obj : error LNK2001: unresolved external symbol __imp__WSASocketA@24
InetFunc.obj : error LNK2001: unresolved external symbol __imp__connect@12
InetFunc.obj : error LNK2001: unresolved external symbol __imp__getservbyport@8
InetFunc.obj : error LNK2001: unresolved external symbol __imp__socket@12
InetFunc.obj : error LNK2001: unresolved external symbol __imp__htons@4
InetFunc.obj : error LNK2001: unresolved external symbol __imp__ntohl@4
InetFunc.obj : error LNK2001: unresolved external symbol __imp__recv@16
Debug/Ping.exe : fatal error LNK1120: 16 unresolved externals
Any ideas what I might be doing wrong?
The WS2_32.dll was in NT4.0 where I got it and put it in the apps compiler directory. Oddly, WS2_32.lib is included in the VCPP 6.0 VC98/bin files.
ReplyOriginally posted by: Chenweijie
I want to programming about Modem Communication and Local
net Communication ,where can I get help?
Originally posted by: Anonymous
Can we get the IP address of a client using winsock in an ISAPI filter?
Reply
Originally posted by: CK Rengasamy
I wrote a program using this class to ping the URL say "www.hotmail.com". I used the "Ping()" method in that program. It returned the following error message. Can anyone help me.
"WSASocket() failed: 10093"
Reply
Originally posted by: Kurt Grittner
You can set these options on any type of socket in any state. The default value for these options is zero, which refers to an infinite time-out. Any other setting is the time-out, in milliseconds. It is valid to set the time-out to any value, but values less than 500 milliseconds (half a second) are interpreted to be 500 milliseconds.
For me, the value of 10 for timeout truly came back in 10 seconds, so every ping was timing out.
Changing
timeout=10;
to
timeout=500;
Did the trick. If a given computer didn't have Winsock 2.0, you could code something like the following after the sendto() but before the recvfrom() :
for (p=0; p<25; p++) {
Thanks for the class.
Regards,
I had trouble with the Ping() function reuturning immediately from the recvfrom() with TIMEOUT. I am using VC++ 6.0 with the latest service pack. Even though the docs say:
bread = recvfrom(sockRaw,recvbuf,MAX_PACKET,0,(struct sockaddr*)&from,&fromlen);
if (bread != SOCKET_ERROR)
break;
Sleep(20);
}
Kurt
Originally posted by: Bruce Grant
...since you called WSAStartup...
Originally posted by: Robert Hamilton
Thanks for such a great piece of code. Being able to ping a host from inside your application is a wonderful
tool. I don't understand ICMP and I'd rather not have to learn.
Thanks again,
Robert Hamilton
Originally posted by: Panna Chowdhury & Venkatesh Iyer
The socket is created without the overlapped I/O attribute. This will cause the recvfrom() call to block forever if the host machine is down - the receive timeout setting will not work. ( Ref. Microsoft KB Article ID: Q181610 )
sockRaw = WSASocket (AF_INET,SOCK_RAW,IPPROTO_ICMP,NULL, 0,0);
The solution is to replace the line above with the following :
sockRaw = WSASocket (AF_INET,SOCK_RAW,IPPROTO_ICMP,NULL, 0,WSA_FLAG_OVERLAPPED);
Reply