Click to See Complete Forum and Search --> : General question about Linux libraries!


Yosuke_
01-21-2005, 06:48 PM
Hello!
For example in socket programming, when I create a simple client, I use header files like:
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netinet/in.h>

And when I compile my code, the required functions are compiled into executable right? But do my Client need some libraries like Windows clients need Winsock libraries? or is all the required things compiled in executable? And for example socket(); connect(); are system calls right? Thank you!

bwkaz
01-21-2005, 08:05 PM
It depends on which Unix OS you're compiling for. :D

On Linux, all the required functions are in glibc, so you get them automatically.

On Solaris, you need to link in some extra libraries when you compile, in order to get network support (you need -lnsl and -lsocket, I believe; maybe also -lresolv).

The actual functions are system calls, yes, but your program does not call the kernel directly. Your program calls a function in glibc (or the nsl/socket library, or whatever) that makes the actual system call. This provides a layer of independence above the kernel, and allows Unix admins to change kernels out with a minimum of hassle (usually, anyway -- assuming the kernel itself is backward compatible, which it basically always is).

In other words, no, you don't need anything like Winsock on Linux.

Yosuke_
01-22-2005, 08:13 AM
Thank you!
So on Linux libraries are like compiled into executable right?

And is Linux socket libraries more powerfull than Winsock? Do they have more functions, more protocols etc...?