Re: ICMP - Raw socket

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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


.



Relevant Pages

  • Re: recvfrom returns with an error code of 14, EFAULT "Bad Address"
    ... the socket up in case I did something wrong. ... The code is at the bottom of the page again. ... recvfrom I am initializing it to NULL. ... the size of the packet received and instead it was the size of the ...
    (comp.unix.programmer)
  • Multithreading Socket Problem
    ... I am trying to implement a ping client that is multithreading. ... approach I have used is to create a ping class which I instantiate ... On reception of data on the socket the callback method referenced by ... is called and I cast the IAsyncResult asyn object to the CSocketPacket ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: call is blocked in recvfrom() and no further proceedings in Wi
    ... I have tested it on real device. ... call is blocked in recvfrom() and no further proceedings). ... >> My program has to send request to service through port 5070(in this port ... Received the response in Windows(means, for reception I created socket ...
    (microsoft.public.windowsce.embedded)
  • ICMP - Raw socket
    ... If i ping my machine from other pcs, ... which means there are some icmp packets reached my machine, ... But if i ping other pcs from my machine, recvfrom returns ...
    (microsoft.public.win32.programmer.networks)
  • Re: UDP packets receiving...
    ... yes i realized that it is already a blocking function and i wrapped it ... non blocking or blocking socket code:- ... (note that if there are multiple UDP packets recieved and waiting ... than recvfrom is a blocking function.... ...
    (microsoft.public.win32.programmer.networks)