IPX/SPX Programming Manual

Sample Programs
HP NonStop IPX/SPX Programming Manual528022-001
6-9
Client and Server Programs Using IPX
stop_advertising(short fnum, char *pServer, short type)
{
unsigned long error;
(void)SAP_STOP(fnum, &error, pServer, type);
(void)SAP_CLOSE(fnum, &error);
return;
} /* End of stop_advertising() */
Client and Server Programs Using IPX
This subsection contains simple client programs and server programs that call the
socket library routines to communicate using the IPX protocol.
IPX Client Program
/*
* Sample IPX client program.
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <socket.h>
#include <nv.h>
#include <netdb.h>
#define DATA_BUF_SIZE 512
#define WELL_KNOWN_PORT 0x5444
main(int argc, char *argv[])
{
struct sockaddr_nv snv;
char buf[DATA_BUF_SIZE];
int bytesSent;
int sock;
/*
* Specify the name of the NonStop IPX/SPX
* Protocol Process if required.
*/
socket_set_nv_name("$NV3A");
/*
* Open a socket.
*/
sock = socket(AF_NV, SOCK_DGRAM, 0);
if (sock < 0) {
perror("socket failure");
exit(1);
}
/*
* Set up the remote address - 4 byte net,
* 6 byte remote host, and 2 byte remote
* port (i.e. remote IPX socket number.)
*/
snv.snv_addr.s_net[0] = 0x00;