Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > X

xopen_networking(7)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

xopen_networking — X/Open Networking Interfaces

DESCRIPTION

X/Open has defined Sockets and IP Address Resolution interfaces in X/Open CAE Specification, Networking Services, Issue 4 (UNIX 95), X/Open CAE Specification, Networking Services, Issue 5 (UNIX 98), and The Single UNIX Specification, Version 3, System Interfaces (UNIX 03).

X/Open has also defined XTI in X/Open CAE Specification, Networking Services, Issue 4 (UNIX 95) and X/Open CAE Specification, Networking Services, Issue 5 (UNIX 98). Beginning in UNIX 03, XTI is no longer part of The Single UNIX Specification.

For more information on the specifications or a detailed description of the X/Open Networking Interfaces, please refer to the above specifications at The Open Group website, http://www.opengroup.org.

Prior to HP-UX 11i v3, HP-UX is certified to UNIX 95 on PA-RISC and Integrity systems. Beginning with HP-UX 11i v3, HP-UX is certified to UNIX 95 on PA-RISC systems and to UNIX 95 and UNIX 03 on Integrity systems.

COMPILATION ENVIRONMENT

There are two ways to obtain X/Open Sockets functionality:

  • Method A is in compliance with X/Open compilation specification.

  • Method B slightly deviates from X/Open compilation specification. However, Method B allows a program to include both objects compiled to X/Open Sockets specification and objects compiled to BSD Sockets specification.

Either cc, c89 or c99 utilities can be used. Refer to cc(1) for details. Also note certain features in UNIX 03 are only available if c99 is used. For example, the "restrict" qualifier for pointers is only available if c99 is used.

Method A) Strict Compliance Method

An X/Open conforming application is one that has all its parts compiled and built according to X/Open specifications. For such conforming applications, this compilation method would be appropriate.

Compilation

UNIX 03

Applications should ensure that the feature test macro _XOPEN_SOURCE is defined with the value 600. To ensure portability, applications should define the macro either on the compilation command line, or at the beginning of each source module prior to the inclusion of any headers.

For example, to compile a 64 bit object using HP ANSI Compiler:

  • c99 +DD64 -D_XOPEN_SOURCE=600 -c main.c -o main.o

    c99 +DD64 -D_XOPEN_SOURCE=600 -c routines.c -o routines.o

UNIX 95

Applications should ensure that the feature test macros _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED are defined. To ensure portability, applications should define the macros either on the compilation command line, or at the beginning of each source module prior to the inclusion of any headers.

For example, to compile a 64 bit object using HP ANSI Compiler:

  • c89 +DD64 -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED -c main.c -o main.o

    c89 +DD64 -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED -c routines.c -o routines.o

Linkage

Link the program objects with Xnet library.

For example:

ld main.o routines.o -lxnet -lc -o prog

Note if the C library is also specified in the link line, the Xnet library has to be specified before the C library. Otherwise, X/Open Sockets calls would have been resolved to BSD Sockets functions in the C library instead of X/Open Sockets functions in the Xnet library.

Method B) Alternative Method

HP-UX provides two styles of Sockets API:

  • default BSD Sockets

  • X/Open Sockets

These two styles of Sockets API have the same function names but they have differences in semantics and argument types. For example, the optlen field in X/Open getsockopt() is size_t type, while BSD getsockopt() is int type. In 64 bit mode, size_t is 64 bit and int is still 32 bit.

Linking objects compiled to X/Open Sockets specification and objects compiled to BSD Sockets specification in the same program using the linkage method in method A would erroneously resolve BSD Sockets calls to X/Open Sockets functions in the Xnet library. As a result, the program may result in application core dumps or unexpected Socket errors when it is run. These symptoms commonly occur when BSD Sockets accept(), getpeername(), getsockname(), getsockopt(), recvfrom(), sendmsg(), and recvmsg() are called.

For such mixed program configuration, the compilation and linkage methods described below in Compilation should be used.

Compilation

Define _HPUX_ALT_XOPEN_SOCKET_API, in addition to either defining _XOPEN_SOURCE=600 in UNIX 03 or _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED in UNIX 95.

For example to compile a 64-bit X/Open Sockets object and a 64-bit BSD Sockets object using HP ANSI Compiler:

UNIX 03

c99 +DD64 -D_XOPEN_SOURCE=600 -D_HPUX_ALT_XOPEN_SOCKET_API -c main.c -o main.o

UNIX 95

c89 +DD64 -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_HPUX_ALT_XOPEN_SOCKET_API -c main.c -o main.o

BSD Sockets

cc -Ae +DD64 -c routines.c -o routines.o

With this method, X/Open Sockets calls are remapped by the static Sockets functions in <sys/socket.h> to an alternative set of X/Open Sockets functions in C library. This alternative set has a prefix _xpg_ in its function names, for example, _xpg_getsockopt().

Because the alternative set has different function names, X/Open Sockets calls are not confused with BSD Sockets calls at link time.

Other than the naming difference, this alternative set is identical to the X/Open Sockets functions in Xnet library. Other than adding an additional macro, _HPUX_ALT_XOPEN_SOCKET_API, this compilation method is compliant to X/Open specifications.

Linkage

Link with C library instead of Xnet library. Xnet library should not be included in the application link line.

For example:

ld main.o routines.o -lc -o prog

Because Xnet library is not in the link line, BSD Sockets calls are not erroneously resolved to X/Open Sockets functions in Xnet library.

FUTURE DIRECTION

Method B might become the default method in a future release. At that time, _HPUX_ALT_XOPEN_SOCKET_API would be defined by default.

AUTHOR

X/Open XTI, Sockets and IP Address Resolution interfaces were developed by HP and X/Open Company Limited.

SEE ALSO

XTI:

t_accept(3), t_alloc(3), t_bind(3), t_close(3), t_connect(3), t_error(3), t_free(3), t_getinfo(3), t_getprotaddr(3), t_getstate(3), t_listen(3), t_look(3), t_open(3), t_optmgmt(3), t_rcv(3), t_rcvconnect(3), t_rcvdis(3), t_rcvrel(3), t_rcvudata(3), t_rcvuderr(3), t_snd(3), t_snddis(3), t_sndrel(3), t_sndudata(3), t_strerror(3), t_sync(3), t_unbind(3).

Sockets:

accept(2), bind(2), close(2), connect(2), fcntl(2), fgetpos(3S), fsetpos(3S), ftell(3S), getpeername(2), getsockname(2), getsockopt(2), listen(2), lseek(2), poll(2), read(1), recv(2), recvfrom(2), recvmsg(2), select(2), send(2), sendmsg(2), sendto(2), setsockopt(2), shutdown(2), sockatmark(3N), socket(2), socketpair(2), write(1).

IP Address Resolution:

gethostname(2), endhostent(3N), endnetent(3N), endprotoent(3N), endservent(3N), freeaddrinfo(3N), gai_strerror(3N), getaddrinfo(3N), gethostbyaddr(3N), getnameinfo(3N), getnetbyaddr(3N), getprotobynumber(3N), getservbyport(3N), htonl(3N), if_freenameindex(3N), if_indextoname(3N), if_nameindex(3N), if_nametoindex(3N), inet_addr(3N), ntohl(3N), sethostent(3N), setnetent(3N), setprotoent(3N), setservent(3N).

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.