home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
ipxex3.exe
/
IPXSEND.CPP
< prev
Wrap
Text File
|
1995-01-27
|
4KB
|
146 lines
/* ***************************************************************************
** File: IPXSEND.CPP
**
** Description:
**
** Sample OS/2 application that demonstrates setting up an IPX
** sender application. This file goes along with IPXRECV.CPP,
** which demonstrates the receiving portion of this code.
**
** Disclaimer:
**
** Novell, Inc. makes no representations or warranties with respect to
** any NetWare software, and specifically disclaims any express or
** implied warranties of merchantability, title, or fitness for a
** particular purpose.
**
** Distribution of any NetWare software is forbidden without the
** express written consent of Novell, Inc. Further, Novell reserves
** the right to discontinue distribution of any NetWare software.
**
** Novell is not responsible for lost profits or revenue, loss of use
** of the software, loss of data, costs of re-creating lost data, the
** cost of any substitute equipment or program, or claims by any party
** other than you. Novell strongly recommends a backup be made before
** any software is installed. Technical support for this software
** may be provided at the discretion of Novell.
**
** Programmers:
**
** Ini Who Firm
** -------------------------------------------------------------------
** DRS Dan Stratton Novell Developer Support
**
** History:
**
** When Who What
** -------------------------------------------------------------------
** 12-09-94 DRS First code.
**
*/
#define NWOS2
#define IS32BIT
#if defined (__BORLANDC__)
#define BCPP
#elif (defined (__IBMC__) || defined(__IBMCPP__))
#define CSET2
#endif
#include <os2.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C"{
#endif
#include <nwcalls.h>
#include <ipxcalls.h>
#ifdef __cplusplus
}
#endif
#define MAX_BUF_SIZE 128
#define IPX_DESTSOCKET 0x4545
#define NUMSENDS 5
IPX_HEADER ipxHeader;
IPX_ECB ipxECB;
BYTE ipxBuffer[MAX_BUF_SIZE];
USHORT ipxSocket;
ULONG transTime;
NWCONN_HANDLE connectionID;
NWCONN_NUM connectionNumber;
BYTE destAddress[11];
NWNET_ADDR NetAddr;
void main(int argc, char *argv[])
{
UINT16 ccode;
char buffChar; /* buffer for character to send */
int i=0;
NWCallsInit(NULL,NULL);
if ( argc != 2 )
{
printf("\nUSAGE: IPXSend <connection #>\n");
DosExit(EXIT_PROCESS,1);
}
ccode = NWGetDefaultConnectionID(&connectionID);
connectionNumber = atoi(argv[1]);
ipxECB.next = NULL;
ipxECB.prev = NULL;
ipxECB.fragCount = 2;
ipxECB.fragList[0].fragAddress = &ipxHeader;
ipxECB.fragList[0].fragSize = sizeof(IPX_HEADER);
ipxECB.fragList[1].fragAddress = ipxBuffer;
ipxECB.fragList[1].fragSize = sizeof(ipxBuffer);
ipxHeader.packetType = 0;
ipxHeader.destSocket = IPX_DESTSOCKET;
NWGetInternetAddress(connectionID,connectionNumber,(NWNET_ADDR NWPTR)&NetAddr);
memcpy(&ipxHeader.destNet,&NetAddr,10);
ccode = IpxGetLocalTarget((BYTE *)&ipxHeader.destNet,&ipxECB,&transTime);
if ( ccode )
{
printf("\nError: IpxGetLocalTarget return %4.4x\n",ccode);
DosExit(EXIT_PROCESS,1);
}
ipxSocket = 0;
ccode = IpxOpenSocket(&ipxSocket);
if ( ccode != 0 )
{
printf("\nError: IpxOpenSocket returned %4.4x\n",ccode);
DosExit(EXIT_PROCESS,1);
}
buffChar = 'A';
for(i=0;i<NUMSENDS;++i)
{
memset(ipxBuffer, buffChar ,sizeof(ipxBuffer));
ccode = IpxSend(ipxSocket,&ipxECB); if ( ccode )
printf("\nError: IpxSend returned %4.4x on packet #%d\n",ccode,i+1);
else
printf("Packet #%d was sent sucessfully.\n",i+1);
buffChar++;
}
IpxCloseSocket(ipxSocket);
}