# sockets



## dalee (May 6, 2001)

how do you include the standard libsocket.a type thing on os x????

we have a program that works fine on redhat, solaris. but not OS-X

is there a framework which should be included?


----------



## JSR COUT (May 8, 2001)

Did you try 

cc hello.c -lsocket

or 

cc hello.c -lbsd

?


----------



## dalee (May 11, 2001)

Nope, neither of those work.

I can't seem to find a library in /etc/lib that is anything to do with sockets. On Solaris it's called socket.a I think.
How do we MacOSX users get to compile programs using Berkeley Sockets -help me because my Solairis Mates are mocking OSX!

I have got programs to compile properly but the sockets calls don't actually work. Do I need to include some library to make it work.


----------



## blb (May 11, 2001)

If you're just looking for things like socket(), bind(), listen() and such, I see them in libc:

$ nm /usr/lib/libc.dylib |egrep ( _socket$| _bind$| _listen$)

700261c0 T _bind
70026200 T _listen
70012550 T _socket

What is the error you receive when compiling/linking?


----------



## ladavacm (May 11, 2001)

OS X is BSDish; no special library is needed to get acces to Berkeley sockets


----------



## dalee (May 20, 2001)

I have absolutely no problems with the application compiling and linking, I get a runnable application, except whenever it tried to call bind() the application fails...
Running it as root to avoid potential refusal of sockets didn't help either.
What could be causing for this? I have run out of ideas....

Dave


----------



## ladavacm (May 21, 2001)

Ah-ha!

How about perror() after the failed bind()?  That way we *might* be able to help you (as opposed to having a snowballs chance in a very hot place 

After instrumenting the program with meaningful error logging, it is much easier to find where things went wrong.

Furthermore, struct sockaddr_xx needs to be fully initialized before passing it to BSD protocol stacks (something neither Linux nor Solaris stacks seem to care too much about).


----------



## dalee (May 29, 2001)

Thank you for all your help. I have now got the problem sorted - I was leaving some parts of some data structures incorrectly filled out. 
I appologise also for not responding sooner because for some reason I wasn't allowed to re-post something to do with cookie problems...
Cheers!
DAVE


----------

