Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 06-17-2004, 10:00 AM   #1
LQ Newbie
Registered: Oct 2003
Posts: 14

Rep: Reputation: 0
Raw socket creation error (IPPROTO_IP not supported)

hi all,

I tried creating a raw socket in Redhat Advanced server 3.0 . Problem is socket creation fails if the protocol family is IPPROTO_IP or IPPROTO_RAW. I checked out the values for these macros in the header file . They are

IPPROTO_IP ---> 255

I am interested in creating a RAW SOCKET (SOCK_RAW) only

. Socket creation succeeds for other protocol family like IPPROTO_TCP of IPPROTO_ICMP .. etc. The following is the code snippet .

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Code Starts here ^^^^^^^^^^^^^^^^^^^^^^^^

#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <errno.h>
#include <iostream.h>

int main()
int fd;
struct sockaddr_in serv_sock,cli_sock;

if ((fd = socket(AF_INET,SOCK_RAW,0)) < 0)
cout<<"error "<<errno<<endl;

//raw sockets dont require binding .. do they ??

fd_set fdset;

int ret = select(fd+1,&fdset,NULL,NULL,NULL);
if (FD_ISSET(fd,&fdset))


printf("program terminates");
return 0;

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Code Ends here ^^^^^^^^^^^^^^^^^^^^^^^^

My problem is only with socket creation using IPPROTO_IP or IPPROTO_RAW ... the value of errno after the call is 94 which is # defined in <asm/errno.h> as

#define ESOCKTNOSUPPORT 94 /* Socket type not supported */

Does redhat AS 3.0 not allow creation of IPPROTO_IP or IPPROTO_RAW type sockets.
do i have to enable the support in kernel.

Thanks a ton in advance !!!

Warm Regards

N.Harris ur rahman
Old 06-17-2004, 10:53 AM   #2
Registered: Mar 2003
Location: Belgium
Distribution: Hardened gentoo
Posts: 323

Rep: Reputation: 30
Don't know about the error you get, but I think you DO need to bind() a raw socket too, since you're still using the IP layer for addressing; it's only the transport layer protocol that is non-{udp|tcp}. So you still need to bind() to an IP address, I think.

Good luck fixing it!

Last edited by nukkel; 06-17-2004 at 10:54 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
socket: Socket type not supported monindra Fedora - Installation 4 01-14-2008 07:25 AM
error: conflicting types for `IPPROTO_IP' Anastasia Linux - Software 0 07-14-2005 06:12 AM
Raw socket creation error (IPPROTO_IP not supported) linfreak Programming 1 06-17-2004 12:37 PM
Socket Raw linuxanswer Programming 1 04-01-2004 09:43 PM
raw ipv6 socket example Steave Programming 0 06-27-2003 03:55 PM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:32 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration