Unix APIs

Discussion in 'Mac Programming' started by CaptainZap, Mar 21, 2008.

  1. macrumors regular

    Joined:
    Jan 17, 2007
    #1
    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.
     
  2. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
  3. thread starter macrumors regular

    Joined:
    Jan 17, 2007
    #3
    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.
     
  4. macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #4
    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
     
  5. thread starter macrumors regular

    Joined:
    Jan 17, 2007
    #5
    K thanks Lee, now I just need to find a good C tutorial/book that talks about the language a little more in depth.
     
  6. macrumors 6502a

    yeroen

    Joined:
    Mar 8, 2007
    Location:
    Cambridge, MA
    #6
    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-Progra...bs_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.
     
  7. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #7
    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 you should be fine.
     

Share This Page