WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: tc to support raw socket?  (Read 570 times)

Offline TTT

  • WikiUser
  • *
  • Posts: 2
tc to support raw socket?
« on: February 24, 2020, 05:37:17 PM »
good day,

i test tinycore and want to use raw socket.
but seems it donest support raw socket.

anyone know to how to use raw socket for tinycore?

thanks in advance.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 8251
Re: tc to support raw socket?
« Reply #1 on: February 24, 2020, 05:54:00 PM »
Hi TTT
Welcome to the forum.
... but seems it donest support raw socket. ...
I don't know why you would think that. This is how I set up a raw socket:
Code: [Select]
/******************************************************************/
/* Configures the socket for the Sniffer routine */
static void SetupRawSockets(void)
{
sniffersock=socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
fcntl(sniffersock, F_SETFL, fcntl(sniffersock, F_GETFL) | O_NONBLOCK);
return;
}
/******************************************************************/
sniffersock is defined as an int.

You can find the source code it came from here:
http://forum.tinycorelinux.net/index.php/topic,22646.msg141958.html#msg141958

Offline TTT

  • WikiUser
  • *
  • Posts: 2
Re: tc to support raw socket?
« Reply #2 on: February 25, 2020, 04:02:03 AM »
thanks so much. i solve my problem now. ;)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 8251
Re: tc to support raw socket?
« Reply #3 on: February 25, 2020, 07:33:48 AM »
Hi TTT
thanks so much. ...
You are welcome.

If you are new to network programming, this is worth checking out. It doesn't cover raw sockets, but it's easy to understand and
covers important concepts. It also has coding samples:
http://beej.us/guide/bgnet/

Raw sockets means you will likely be packing data structures. This large site covers many protocols and the data layout of
their respective packets:
http://www.tcpipguide.com/free/index.htm