View Full Version : Unix APIs
Mar 21, 2008, 07:25 PM
I've been reading about BSD sockets and a lot of other Unix functions that I don't understand. And I am wondering if anyone knows some good online tutorials or books that go more into depth on Unix APIs and a good C book.
Mar 21, 2008, 07:28 PM
Advanced Programming in the UNIX Environment (http://www.amazon.co.uk/Programming-Environment-Addison-Wesley-Professional-Computing/dp/0201433079/ref=sr_1_1?ie=UTF8&s=books&qid=1206141942&sr=1-1) was recommend to me by someone on this forum and is a very good book to get you going.
Unix Network Programming: Sockets Networking (http://www.amazon.co.uk/Unix-Network-Programming-Addison-Wesley-Professional/dp/0131411551/ref=sr_1_2?ie=UTF8&s=books&qid=1206142055&sr=1-2) has also had some very good reviews but I can't afford it at the moment :).
Mar 21, 2008, 08:42 PM
Alright sweet, thanks. I was actually thinking of PMing you directly and asking :)
Oh, and I'm wondering about how much C knowledge is necessary. I've read Programming in Objective-C and know the syntax well but I don't think my C is very good.
Mar 21, 2008, 09:47 PM
Unix APIs are all C. Unix and C are best friends. Other languages essentially all end up using the C routines for getting at the system. For example, perl is in C, the JVM is in C, etc. Any call to a UNIX API will be the description of the C call. Obviously things that can call directly into C can use the APIs as well.
Essentially you will find out what methods you need, and look at a description in a book, the man page, or something online. You'll need to find out what header file (.h) you need to include to use the function, and what types you have to pass in. Many system functions use pointers to special structs as arguments. Normally these will be defined in a .h file as well.
If it's not your forte it might take some time to adjust to some of the UNIXisms, like "everything is a file". When you open a socket, it's a file descriptor. You just poke at it in slightly different ways.
Mar 21, 2008, 10:42 PM
K thanks Lee, now I just need to find a good C tutorial/book that talks about the language a little more in depth.
Mar 21, 2008, 10:56 PM
What Cromulent said. The Stevens' books are the standard reference for C "systems" programming.
Other invaluable resources:
The online GNU C library reference manual:
(be sure to check your system man pages to check for divergences)
The comp.lang.c FAQ:
Another must read is Expert C programming:
from which I learned as much as I ever did from Stevens or Kernighan and Richie.
Mar 22, 2008, 07:26 AM
Oh, and I'm wondering about how much C knowledge is necessary.
Not that good. As long as you understand concepts such as arrays, structs, malloc et al, basic pointers etc and can get by reading reference material such as The GNU C Library (http://www.gnu.org/software/libc/manual/html_node/index.html) you should be fine.