C and sockets programming

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

  1. aaronw1986 macrumors 68030

    Joined:
    Oct 31, 2006
    #1
    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

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #2
    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.

    Code:
    #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>
    
    Todd
     
  3. stupidregister macrumors member

    Joined:
    Sep 29, 2007
    #3
    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