Solaris sockets libraries.


R. Clayton (rclayton@clayton.cs.monmouth.edu)
(no date)


If you're compiling sockets code on solaris, you need to include the socket and
nsl libraries go get access to the sockets api:

  $ g++ -o tcp-daytime -g tcp-daytime.o ip-utils.o -lsocket -lnsl

  $

If you forget them, the sockets api routines will come up missing:

  $ g++ -o tcp-daytime -g tcp-daytime.o ip-utils.o
  Undefined first referenced
   symbol in file
  socket ip-utils.o
  getprotobyname ip-utils.o
  gethostbyname ip-utils.o
  accept ip-utils.o
  bind ip-utils.o
  getservbyname ip-utils.o
  inet_addr ip-utils.o
  listen ip-utils.o
  connect ip-utils.o
  ld: fatal: Symbol referencing errors. No output written to tcp-daytime
  collect2: ld returned 1 exit status

  $

If you forget the names or order of the libraries (as I always do), you can
type "man socket" to get a reminder:

  $ man socket
  Reformatting page. Wait... done

  Network Functions socket(3N)

  NAME
       socket - create an endpoint for communication

  SYNOPSIS
       cc [ flag ... ] file ... -lsocket -lnsl [ library ... ]
       #include <sys/types.h>
       #include <sys/socket.h>

       int socket(int domain, int type, int protocol);

  DESCRIPTION
       socket() creates an endpoint for communication and returns a
       descriptor.

       The domain parameter specifies a communications domain
       within which communication will take place; this selects the
       protocol family which should be used. The protocol family
       generally is the same as the address family for the
       addresses supplied in later operations on the socket. These

  [and so on]

Running man on most of the sockets api routines should give you the same
information.



This archive was generated by hypermail 2.0b3 on Sun May 06 2001 - 20:30:05 EDT