C and sockets programming

Discussion in 'Mac Programming' started by aaronw1986, Oct 20, 2007.

  1. aaronw1986 macrumors 68030

    Oct 31, 2006
    I have a programming assignment dealing with sockets. My professor said we might need to compile using -lsocket. However, I receive, "/usr/bin/ld: can't locate file for: -lsocket" when I try to do so. Do I not need to use this command in OS X?
  2. toddburch macrumors 6502a

    Dec 4, 2006
    Katy, Texas
    I've started writing a sockets program myself. Other than pulling in the appropriate header files, I'm just using a "Standard Tool" project in XCode and I have added no additional libraries.

    #include <stdio.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    // for struct sockaddr_in 
    #include <netinet/in.h> 
    // for memset 
    #include <strings.h> 
    // for getprotoent   
    #include <netdb.h>
  3. stupidregister macrumors member

    Sep 29, 2007
    You don't need that argument. The socket library is not a separate library like in you professor's system (presumably Solaris).

Share This Page