TCPware V5.7 Programmer's Guide

Previous Page TOC Index Next Page



Chapter 8

Socket Library

Introduction

This chapter describes the Socket Library to use for your particular programming application.

TCPware provides a Socket Library if you are running a version of VMS earlier than 5.3 or are using the Remote Procedure Call (RPC) routines. However, Process Software does not recommend that you use the TCPware Socket Library for later versions of OpenVMS.

HP provides a C Socket Library you should use for VMS Version 5.3 and later. HP provides a collection of VAX C, DEC C, and DEC C++ subroutines that closely emulates the UNIX socket functions.

Note! For OpenVMS V5.3 and later, whether the compiler is VAX C, DEC C or DEC C++, network programmers should use HP’s C Socket Library routines and header files. In the case of the compiler being DEC C or C++, programmers MUST use HP's library and header files. This applies to VAX, Alpha and I64 systems.

See HP’s VAX C Run Time Library Manual or DEC C Language Reference Manual for information on these socket library routines.

See Appendix A, for details on the TCPware Socket Library routines.

Transitioning to the C Socket Library: Include (Header) Files

HP provides header files for its C Socket Library that are similar to those provided by TCPware.

The header files TCPware provides in its Socket Library are described in Appendix A.

To use the HP C Socket Library header files:

If you are transitioning an existing VAX C socket application, change any #include statements for TCPware's header files to reference HP's header files. For example:

#include "tcpware_include:netdb.h"

becomes:

#include <netdb.h>

Then compile as follows:

– On the VAX C command line:

$ cc prog.c

– On the DEC C command line for VAX:

$ cc /stand=vaxc prog.c

– On the DEC C command line for Alpha and I64:

$ cc /stand=vaxc/nomember_align/assume=noaligned prog.c

If you are porting or developing an ANSI C or C++ application, use the HP header files as shown above. Then compile the application (in the case of DEC C, omit the
/stand=vaxc option).

Note! If you are developing a new program using DEC C, compile using:

$ cc /prefix_library_entries=all_entries prog.c

Transitioning to the C Socket Library:
Linking Applications

You can then link against HP's C Socket Library as follows:

For VAX C:

$ link prog,sys$input/options
tcpware:ucx$ipc/lib
sys$share:vaxcrtl/share

For DEC C on the VAX, Alpha and I64, and for DEC C++:

$ link prog

The link procedure for the TCPware Socket Library is described in Socket Library.

Sample Programs

The following sample programs are included in the TCPWARE_COMMON:[TCPWARE.EXAMPLES] directory:

TCP_SOCKET_CLIENT.C

TCP_SOCKET_SERVER.C

UDP_SOCKET_CLIENT.C

UDP_SOCKET_SERVER.C

The TCP_SOCKET_CLIENT.C and TCP_SOCKET_SERVER.C pair of programs provide a self-declared ECHO server that sequentially accepts client connections and echoes back the client messages. The UDP_SOCKET_CLIENT.C and UDP_SOCKET_SERVER.C pair of programs provide a self-declared DISCARD server that can receive (and discard) datagrams from multiple clients.

These programs are functionally equivalent to the BGDRIVER sample programs in Chapter 2, UCX Compatibility Services.

To build any one of these applications using DEC C, enter:

$ CC/DECC/PREFIX=ALL filename
$ LINK filename
Ctrl/Z

To build any one of these applications using VAX C, enter:

$ CC/VAXC filename
$ LINK filename, TCPWARE:UCX$IPC/LIB, SYS$INPUT/OPTIONS-
_$ SYS$SHARE:VAXCRTL/SHARE
Ctrl/Z

Appendix A, TCPware Socket Library, includes sample programs for the TCPware Socket Library. These require minor modification to be used in C Socket Library applications.

Previous Page Page Top TOC Index Next Page