msantos / procket

Erlang interface to low level socket operations

Home Page:http://blog.listincomprehension.com/search/label/procket

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when trying to ping 127.0.0.1

infospacer opened this issue · comments

I'm trying to ping using icmp from examples
26> icmp:ping("127.0.0.1").
** exception error: no function clause matching
icmp:icmp(<<8,0,176,193,100,172,0,0,0,0,5,89,0,14,175,9,0,1,155,
119,32,33,34,35,36,37,38,39,...>>) (src/icmp.erl, line 120)
in function icmp:loop/1 (src/icmp.erl, line 75)

At the same time trying another address 192.168.20.9 everythig is ok

28> icmp:ping("192.168.20.9").
ok
29>
=INFO REPORT==== 31-May-2013::11:07:14 ===
type: 0
code: 0
checksum: 40081
id: 53808
sequence: 0
payload: <<" !"#$%&'()*+,-./0123456789:;<=>?@abcdefghijk">>
time: 15998

Hey! Thanks for the bug report!

The icmp:ping/1,2 example only checks for ICMP echo reply packets. When you ping localhost, the ICMP socket sees the echo request that you send and the reply.

I modified the example to filter out the echo request packets. To keep things simple, it will still crash if any other ICMP types are seen by the socket.

icmp:icmp(< 119,32,33,34,35,36,37,38,39,...>>)

I guess you obfuscated the error trace?

Thanks again and if you have any more problems or questions, let me know!

Thank you very much!

Everything works now.