# Raw Sockets

**URL:** <https://forums.digi.com/t/raw-sockets/5686>\
**Category:** NET+OS\
**Created:** [July 24, 2003, 4:02pm UTC](https://forums.digi.com/t/raw-sockets/5686 "2003-07-24T16:02:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/digi/original/1X/11da31a6a1fbcd03ef21d3f785c317c824009ae2.png) [@system](https://forums.digi.com/u/system)\
**Post date:** [July 24, 2003, 4:02pm UTC](https://forums.digi.com/t/raw-sockets/5686/1 "2003-07-24T16:02:22Z")

</div>

I have a need to receive packets that are not ether type IP or ARP. I don’t need to send them, but I do need to receive them. Is there any way to accomplish this? I don’t care if I have to use an API other than the sockets api. Right now I’m using the NS7520 development board. Thanks! Kevin

---

<div class="post-metadata">

**Author:** ![uniton](https://avatars.discourse-cdn.com/v4/letter/u/5daacb/32.png) [@uniton](https://forums.digi.com/u/uniton)\
**Post date:** [May 19, 2005, 2:23pm UTC](https://forums.digi.com/t/raw-sockets/5686/2 "2005-05-19T14:23:50Z")

</div>

In Net+OS 6.0 raw sockets are possible. Just use SOCK\_RAW as type of socket. Unfortunately this is NOT described in the API reference…

---

<div class="post-metadata">

**Author:** ![muscleman](https://avatars.discourse-cdn.com/v4/letter/m/f1d935/32.png) [@muscleman](https://forums.digi.com/u/muscleman)\
**Post date:** [July 25, 2003, 11:21am UTC](https://forums.digi.com/t/raw-sockets/5686/3 "2003-07-25T11:21:46Z")

</div>

With the current releases of Net+Os there is no raw socket api that would allow you to accomplish what you are looking for however this api will be part of Net+Os v6.0. You may want to contact Technical support department to see if they have any other solution as an add on.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/digi/original/1X/11da31a6a1fbcd03ef21d3f785c317c824009ae2.png) [@system](https://forums.digi.com/u/system)\
**Post date:** [July 29, 2003, 9:47pm UTC](https://forums.digi.com/t/raw-sockets/5686/4 "2003-07-29T21:47:06Z")

</div>

I found a fairly easy way to do it. I hooked into the bsp ethernet code in eth\_recv\_up() and after a quick look at the packet, I use a message queue to send the message structure to my app code via a message queue if the packet is the type I’m looking for. It is only a little bit hacky this way. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/digi/original/1X/11da31a6a1fbcd03ef21d3f785c317c824009ae2.png) [@system](https://forums.digi.com/u/system)\
**Post date:** [July 28, 2005, 9:35am UTC](https://forums.digi.com/t/raw-sockets/5686/5 "2005-07-28T09:35:48Z")

</div>

I’ve tried the SOCK\_RAW parameter too, but I doesn’t get any packets. Could anybody take a look on my codesample please?!

---

<div class="post-metadata">

**Author:** ![uniton](https://avatars.discourse-cdn.com/v4/letter/u/5daacb/32.png) [@uniton](https://forums.digi.com/u/uniton)\
**Post date:** [August 15, 2005, 12:18pm UTC](https://forums.digi.com/t/raw-sockets/5686/6 "2005-08-15T12:18:09Z")

</div>

Try to enable socket option IP\_HDRINCL. This option name is not predefined by Net+OS. #define IP\_HDRINCL 2 int on = 1; setsockopt(sock,IPPROTO\_IP,IP\_HDRINCL,(char \*)&on,sizeof(on));

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/digi/original/1X/11da31a6a1fbcd03ef21d3f785c317c824009ae2.png) [@system](https://forums.digi.com/u/system)\
**Post date:** [August 29, 2005, 9:38pm UTC](https://forums.digi.com/t/raw-sockets/5686/7 "2005-08-29T21:38:47Z")

</div>

I’m working on a product, which need transfer raw data between ethernet and serial port transparently. Does raw socket can do this function?

---

<div class="post-metadata">

**Author:** ![uniton](https://avatars.discourse-cdn.com/v4/letter/u/5daacb/32.png) [@uniton](https://forums.digi.com/u/uniton)\
**Post date:** [September 8, 2005, 3:06pm UTC](https://forums.digi.com/t/raw-sockets/5686/8 "2005-09-08T15:06:24Z")

</div>

i think you rather should use a protocol like udp.
