Networking
cancel
Showing results for 
Search instead for 
Did you mean: 

HP-UX X/Open Socket and BSD Socket Issue

yourmani
Frequent Visitor

HP-UX X/Open Socket and BSD Socket Issue

I am using HP-UX(B.11.31). PostgreSQL uses X/Open Sockets. If we cannot use X/Open Socket and BSD Socket objects files in same 64bit binary. Is it safe to link 64bit PostgreSQL or any other X/Open Socket app with libraries ship with HP-UX OS packages e.g. openssl.OPENSSL-LIB or KRB5-Client.KRB5-IA64SLIB that are BSD Socket without using _HPUX_ALT_XOPEN_SOCKET_API. Thanks.

 

Reference :-
man 
 
 xopen_networking
...
...
      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.
...
...
man socket
...
...
      Currently, the default behavior is the HP-UX BSD Sockets; however, it
      might be changed to X/Open Sockets in a future release.  At that time,
      any HP-UX BSD Sockets behavior that is incompatible with X/Open
      Sockets might be obsoleted.  Applications that conform to the X/Open
      specification now will avoid migration problems (see
      xopen_networking(7)).
...

 

1 REPLY
Laurent Menase
Honored Contributor

Re: HP-UX X/Open Socket and BSD Socket Issue

Hi,

no it is not safe, because some API doesn't match, for instance accep(), getpeername(), getsockname(), getsockopt(), recvfrom(),      sendmsg(), and recvmsg(), expect 32 bits  size  in one case and 64 bit in the other.

So you need that libxnet be not used by any of your library or application

 

So you need to compile any of the application/library  using xopen socket with also   -D_HPUX_ALT_XOPEN_SOCKET_API option, like that xopen socket don't need the application to be linked with libxnet, and will avoid the mismatch between the 2 api

quote..

     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.
endofquote