Re: ping a server in vc.net
Well...what does not work?
Re: ping a server in vc.net
the application is giving linking errors
Re: ping a server in vc.net
Well...what linker errors?
Re: ping a server in vc.net
error LNK2019: unresolved external symbol __imp__WSACleanup@0 referenced in function _WinMain@16
error LNK2019: unresolved external symbol __imp__gethostbyaddr@12 referenced in function _WinMain@16
error LNK2019: unresolved external symbol __imp__gethostbyname@4 referenced in function _WinMain@16
error LNK2019: unresolved external symbol __imp__WSAStartup@8 referenced in function _WinMain@16
these are linking errors i am getting when i execute the same code in vc.net,
Re: ping a server in vc.net
Code:
#pragma comment (lib, "ws2_32")
Re: ping a server in vc.net
i tried #pragma comment (lib, "ws2_32") but still i am getting the same errors
Re: same problem with winsock32.dll
hi,
i had the same linking problem with winsock32.dll. the code compiled fine, but i couldn't link to the mentioned dll -- unresolved externals on dll functions. couldn't find a solution
Re: ping a server in vc.net
Well...that is interesting...can you post a compilable sample program which recreates the error?
Re: ping a server in vc.net
Quote:
Oiriginally posted by Andreas Masur
Well...that is interesting...can you post a compilable sample program which recreates the error?
Well, I don't have the source code of the program here (at my job). I tried to develop the client/server winsock based program some years ago when i was learning visual c++, it was for learning purposes only, and after getting the unresolved external errors i gave up after a while. i don't know if i still have the
source code on my home computer. however, the questions remain, since then
i wasn't confronted with internet socket programming again.
Re: ping a server in vc.net
the core part of the code is
#include "stdafx.h"
#include "Pingnet.h"
#include "PingnetDlg.h"
#include"winsock2.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
void abc(char *p)
{
FILE *fp=fopen("TraceNet.TXT","a+");
fprintf(fp,"%s\n",p);
fclose(fp);
}
struct o
{
unsigned char Ttl;
unsigned char a[7];
};
struct
{
DWORD Address;
unsigned long Status,RoundTripTime;
unsigned char a[8];
struct o Options;
} E;
HANDLE hIP;WSADATA wsa;HANDLE hIcmp;DWORD *dwIPAddr;struct hostent *phostent;
DWORD d;char aa[100];struct o I;char bb[100];int z;
HANDLE ( WINAPI *pIcmpCreateFile )( VOID );
BOOL ( WINAPI *pIcmpCloseHandle )( HANDLE );
DWORD (WINAPI *pIcmpSendEcho) (HANDLE,DWORD,LPVOID,WORD, LPVOID,LPVOID,DWORD,DWORD);
void CPingnetDlg::OnBnClickedOk()
{
hIcmp = LoadLibrary( "ICMP.DLL" );
WSAStartup( 0x0101, &wsa );
pIcmpCreateFile = (HANDLE (WINAPI *)(void))
GetProcAddress((HMODULE)hIcmp,"IcmpCreateFile");
pIcmpCloseHandle = (BOOL (WINAPI *)(HANDLE))
GetProcAddress((HMODULE)hIcmp,"IcmpCloseHandle");
pIcmpSendEcho = (DWORD (WINAPI *)
(HANDLE,DWORD,LPVOID,WORD, LPVOID,LPVOID,DWORD,DWORD))
GetProcAddress((HMODULE)hIcmp,"IcmpSendEcho");
hIP = pIcmpCreateFile();
for ( z = 1; z<= 20 ; z++)
{
I.Ttl=(unsigned char)z;
// phostent = gethostbyname( "66.28.63.63");
phostent = gethostbyname( "64.246.52.100");
// phostent = gethostbyname( "66.98.128.62");
dwIPAddr = (DWORD *)( *phostent->h_addr_list );
pIcmpSendEcho(hIP,*dwIPAddr,0,0,&I,&E,sizeof(E),8000 );
d=E.Address;
phostent = gethostbyaddr((char *)&d,4,PF_INET);
if ( phostent != 0)
strcpy(aa,phostent->h_name) ;
else
strcpy(aa,"no host name");
wsprintf(bb," RTT: %dms, TTL: %d", E.RoundTripTime, E.Options.Ttl );
strcat(aa,bb);
abc(aa);
if ( E.Options.Ttl )
{
AfxMessageBox("Pinging");
break;
}
}
pIcmpCloseHandle( hIP );
FreeLibrary((HMODULE)hIcmp);
WSACleanup();
// TODO: Add your control notification handler code here
//OnOK();
}
this code worked fine in vc++ 6.0 but not vc.net
Re: ping a server in vc.net
give it a try with
Code:
#pragma comment(lib, "winsock32.dll")
just curious
Re: ping a server in vc.net
still it is not working with #pragma comment(lib, "winsock32.dll")
Re: ping a server in vc.net
is there anyway to solve my problem
Re: ping a server in vc.net
can anyone bring me out of this labyrinth
Re: ping a server in vc.net
Re: ping a server in vc.net
Well...can you post your project (excluding the debug/release directories) here?
1 Attachment(s)
Re: ping a server in vc.net
I am sending the compilable form of pinging server.I want this code to work in vc.net .Currently it is working in vc++ 6.0
One more thing when i execute the program in vc 6.0 during the pinging the program goes into "Not Responding" mode .
Re: ping a server in vc.net
I am still looking for help
Re: ping a server in vc.net
You should probably try:
Project > XXXX Properties > Configuration Properties > Linker > Input > Additional Dependencies
Adding ws2_32.lib there took care of the unresolved external (LNK2019) errors I was getting on some code that worked in VC6 but not VC7 (.NET).
Cheers,
-Noah