PDA

View Full Version : Unix APIs




CaptainZap
Mar 21, 2008, 06: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.



Cromulent
Mar 21, 2008, 06: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 :).

CaptainZap
Mar 21, 2008, 07: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.

lee1210
Mar 21, 2008, 08: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.

good luck!

-Lee

CaptainZap
Mar 21, 2008, 09: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.

yeroen
Mar 21, 2008, 09: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:

http://www.gnu.org/software/libc/manual/html_node/index.html

(be sure to check your system man pages to check for divergences)

The comp.lang.c FAQ:
http://c-faq.com/

Another must read is Expert C programming:

http://www.amazon.com/Expert-Programming-Peter-van-Linden/dp/0131774298/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1206154466&sr=8-1

from which I learned as much as I ever did from Stevens or Kernighan and Richie.

Cromulent
Mar 22, 2008, 06: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.