#include <ncpext.h>int NWSendNCPExtensionRequest ( LONG NCPExtensionID, const void *requestData, LONG requestDataLen, void *replyData, LONG *replyDataLen);
0 | (0x00) | SUCCESSFUL |
1-16 | - | A communications error has occurred. (See <niterror.h>.) |
126 | (0x7E) |
ERR_NCPEXT_TRANSPORT_PROTOCOL_VIOLATION
The message transport mechanism entered a bad state in the protocol. |
150 | (0x96) |
ERR_NO_ALLOC_SPACE
There was not enough memory available on the server to allocate space for the message. |
252 | (0xFC) |
ERR_NCPEXT_SERVICE_PROTOCOL_VIOLATION
The service provider tried to return more data than the reply buffer could hold. |
254 | (0xFE) |
ERR_NCPEXT_NO_HANDLER
The NCP exception handler could not be found. |
NCPExtensionID is ID of the NCP Extension. This can be obtained with a call to NWGetNCPExtensionInfo (NLM) or NWScanNCPExtensions.
The requestData parameter is a pointer to a buffer the client uses to communicate with your NCP Extension handler. You specify the length of the buffer with requestDataLen. NWSendNCPExtensionRequest sends requestDataLen bytes of the buffer to the server. If requestData is set to NULL or if requestDataLen is set to zero, no request data is sent.
The replyData parameter is a pointer to a buffer that has a size of replyDataLen bytes. When the NCP Extension handler finishes its service, NWSendNCPExtensionRequest copies up to replyDataLen bytes from the server and place them into the replyData buffer. It then sets replyDataLen to reflect the actual number of bytes transferred. If replyData is set to NULL, or if replyDataLen is set to zero, no reply data is returned.
The request and reply buffers of the client must be reproduced on the server, so the maximum size of the buffers you can use depends upon the memory available on the server that registers the NCP extension. When NWSendNCPExtensionRequest is called, it attempts to allocate server memory for two message buffers of size (in bytes) requestDataLen and replyDataLen. If it cannot allocate the space, it returns ERR_NO_ALLOC_SPACE. If this function returns ERR_NO_ALLOC_SPACE, you might retry several times, because server memory use is dynamic.
For a description of NCP extensions, see ``NCP extensions''.
NWSendNCPExtensionRequest
/*echoclnt.c -- the client program for the ECHO SERVER NCP extension*/ #include <nwncpext.h> #include <stdio.h> #include <advanced.h> #include <process.h> #include <nwconn.h> #include <conio.h> #define CTRL_Z 0x1A
void main(void) { LONG NCPExtID; char serverUserCombo[96]; char chr, rtnChr; LONG rtnSize; struct queryDataStruct { LONG CharsEchoed; LONG unused[7]; } queryData; printf("\nEnter login [fileserver/]username to access echo server:"); scanf("%s", serverUserCombo); LoginToFileServer(serverUserCombo, 1, "); /* we will ignore the version and revision information*/ NWGetNCPExtensionInfo("ECHO SERVER", &NCPExtID, NULL, NULL, NULL, &queryData); printf("ECHO SERVER reports %ld characters echoed so far.\nKeystrokes will" "be echoed on the ECHO SERVER's screen, and echoed locally\nafter they " "are returned from the ECHO SERVER\n(Enter ctrl-z to quit)\n", queryData.CharsEchoed); rtnSize = 1; while((chr = getch()) != CTRL_Z) /* checking for ctrl-z to exit*/ { NWSendNCPExtensionRequest(NCPExtID, &chr, sizeof(chr), &rtnChr, &rtnSize); putchar(rtnChr); } }