Can't write a message using ICMP-Socket

Hi all,
I’ve posted a question(“ICMP Socket on QNX v6”) before but there was no
answer so far.


Usually we create a socket by using ‘socket( …,IPPROTO_GRE )’
and write a message by using ‘write( … )’. By the same way, there was no
error or warning message when a ICMP-Socket was created by using
‘socket( …, IPPROTO_ICMP )’, but can’t write any message by using this
socket.
I don’t know what the problem is…

If there was some option I missed when I created a ICMP-Socket, please let
me know.
I’ll be very happy to hear your answer.

Have a nice day…

Jang-Hun

JangHun <khun25@hotmail.com> wrote:

Hi all,
I’ve posted a question(“ICMP Socket on QNX v6”) before but there was no
answer so far.


Usually we create a socket by using ‘socket( …,IPPROTO_GRE )’
and write a message by using ‘write( … )’. By the same way, there was no
error or warning message when a ICMP-Socket was created by using
‘socket( …, IPPROTO_ICMP )’, but can’t write any message by using this
socket.
I don’t know what the problem is…

If there was some option I missed when I created a ICMP-Socket, please let
me know.
I’ll be very happy to hear your answer.

You may want to post your “not working” piece of code, so people could
point out “why”. socket(AF_INET, SOCK_RAW, IPPROTO_ICMP) is OK, and
should work (that’s how ping works).

Now, here is a very wild guess. You forgot to do a “bind()” before you
“write()”. thus, the stack won’t know “where to send” the packet.
An alternative is using “sendto()” instead of “write()”.

-xtang

Thanks…
You are right, I forgot to call ‘init_socket()’ which initialize the socket
after creating this method…

Thanks again and have a nice day…

Jang-Hun

p.s.
If you read the message titled “Using socket on QNX v.6”, you can see the
code I wrote…


“Xiaodan Tang” <xtang@qnx.com> wrote in message
news:9ug550$bfj$1@nntp.qnx.com

JangHun <> khun25@hotmail.com> > wrote:
Hi all,
I’ve posted a question(“ICMP Socket on QNX v6”) before but there was no
answer so far.


Usually we create a socket by using ‘socket( …,IPPROTO_GRE )’
and write a message by using ‘write( … )’. By the same way, there was
no
error or warning message when a ICMP-Socket was created by using
‘socket( …, IPPROTO_ICMP )’, but can’t write any message by using this
socket.
I don’t know what the problem is…

If there was some option I missed when I created a ICMP-Socket, please
let
me know.
I’ll be very happy to hear your answer.

You may want to post your “not working” piece of code, so people could
point out “why”. socket(AF_INET, SOCK_RAW, IPPROTO_ICMP) is OK, and
should work (that’s how ping works).

Now, here is a very wild guess. You forgot to do a “bind()” before you
“write()”. thus, the stack won’t know “where to send” the packet.
An alternative is using “sendto()” instead of “write()”.

-xtang