Search code examples
macossocketsnetwork-programmingincludesctp

SCTP missing include file on OSX?


I was messing around with sockets, and I wanted to test out using the SCTP protocol on my mac.

However, when I try to include the file netinet/sctp.h the compiler gives me a 'file not found' error.

So I did some digging, and sure enough, there is no include file for netinet/sctp.h on Mac OSX Lion. Why is that, when I can set up a socket with IPPROTO_SCTP, and it builds fine?

So, in summary, I have two questions:

  • Where are the headers for SCTP on Mac OSX?
  • Can I still set up a SCTP server without the proper headers? If so, how?

Solution

  • On Lion IPPROTO_SCTP is defined in netinet/in.h - that's why it worked just fine since you probably included netinet/in.h directly or indirectly. However, it is only present in Lion, not in any earlier OS X versions. (Note that netinet/sctp.h is not part of POSIX an I don't think it's portable)