Re: ICMP - Raw socket
- From: "Arkady Frenkel" <arkadyf@xxxxxxxxxxxxxxxx>
- Date: Sun, 9 Oct 2005 18:30:32 +0200
Try catch them with http://www.codeguru.com/network/ipmon.html
Arkady
"Senthil" <Senthil@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:6BE31960-FDC7-44D0-BD36-E03ADE9754C4@xxxxxxxxxxxxxxxx
> Hi All,
> I am trying to use a icmp socket to receive all the icmp packets
> that
> reaches my machine. If i ping my machine from other pcs, ping is sucessful
> which means there are some icmp packets reached my machine, but recvfrom
> never returns. But if i ping other pcs from my machine, recvfrom returns
> immediately. Could anyone let me know how can resolve this issue?
>
> Here is the code
>
> ZeroMemory(&sLocalSock,sizeof(sLocalSock));
>
> sLocalSock.sin_family = AF_INET;
>
> sLocalSock.sin_addr.S_un.S_addr = inet_addr("172.20.211.72");
>
> //creating the socket
> m_sAdvSocket=socket(AF_INET,
> SOCK_RAW,
> IPPROTO_ICMP);
>
>
> if(m_sAdvSocket==INVALID_SOCKET)
> {
>
> wsprintf(szTempError,"%d no. Error in creating socket in
> advertisement",WSAGetLastError());
> MessageBox(NULL,szTempError,"Error",0);
> return 0;
>
>
> }
>
>
> iAdvSockError=bind(m_sAdvSocket,
>
> (SOCKADDR *)&sLocalSock,
>
> sizeof(sLocalSock));
>
> if(iAdvSockError== SOCKET_ERROR)
> {
>
> wsprintf(szTempError,"%d no. Error in binding socket in
> advertisement",WSAGetLastError());
> MessageBox(NULL,szTempError,"Error",0);
> return 0;
>
>
> }
>
>
>
>
>
>
> int iSize=sizeof(sLocalSock);
>
> char szIp[3500];
>
> if(SOCKET_ERROR==recvfrom(m_sAdvSocket,(char *)&szIp,3400,0,(struct
> sockaddr *)&sLocalSock,&iSize))
> {
> wsprintf(szTempError,"%d no. Error in receiving in
> advertisement",WSAGetLastError());
> MessageBox(NULL,szTempError,"Error",0);
> return 0;
>
> }
>
>
> Thanks,
> Senthil
.
- References:
- ICMP - Raw socket
- From: Senthil
- ICMP - Raw socket
- Prev by Date: Re: Checking if WSA already has started up
- Next by Date: Re: tools for detecting performance bottleneck and deadlocks
- Previous by thread: ICMP - Raw socket
- Next by thread: Multicast addressing and Microsoft loopback adapter
- Index(es):
Relevant Pages
|