Article View: comp.protocols.ibm
Article #1410NBSEND2.C (needs NBRCV2.C)
From: TRADER
Date: Tue, 27 Sep 1988 01:33
Date: Tue, 27 Sep 1988 01:33
99 lines
3812 bytes
3812 bytes
/* NBSEND2.C - test of NetBIOS- sends a datagram - Paul McGinnis */
/* AST Research, Inc. - Data Comm Support - Dept. 430 */
/* September 1988. - comments added 9/26/88 */
/* */
/* General calling sequence for NetBIOS calls: */
/* 1. Set up NCB (Network Control Block) */
/* 2. Make ES:BX point to NCB structure */
/* 3. Load AX with 100h */
/* 4. Generate an INT 5Ch */
/* */
/* NetBIOS commands and definitions in NETBIOS.H */
/* */
/* Compilation information: */
/* Compiler: Borland Turbo C v1.5 */
/* Memory model: Small */
/* Floating point support: none */
#include <dos.h>
#include <stdio.h>
#include <netbios.h>
#include <stdlib.h>
#include <string.h>
main()
{
NCB * send_block;
char * send_message;
char * session;
char * rcvr;
unsigned char ret_code, net_num, iflag;
send_block = (NCB *) malloc(sizeof(NCB));
send_message = (char *) malloc(80);
session = (char *) malloc(16);
rcvr = (char *) malloc(16);
_AH = 0;
geninterrupt(0x2a); /* Check to see if NetBIOS is loaded */
iflag = _AH;
if (!iflag)
{
puts(" *** ERROR - NetBIOS not installed. ***");
return;
}
printf("Enter session name: ");
gets(session);
printf("Enter receiver's name: ");
gets(rcvr);
printf("Enter message: ");
gets(send_message);
puts("generating network name...");
send_block -> NCB_COMMAND = ADD_NAME_WAIT;
send_block -> NCB_LANA_NUM = 0;
send_block -> NCB_STO = 0;
send_block -> NCB_RTO = 0;
strncpy(send_block -> NCB_NAME, session, 16);
strncpy(send_block -> NCB_CALLNAME, "*", 16);
_ES = _DS;
_BX = send_block;
_AX = 0x100;
geninterrupt(0x5c);
ret_code = _AL;
net_num = send_block -> NCB_NUM;
if (ret_code)
{
printf("Bad return code = %02Xh\n", ret_code);
return;
}
printf("Session established. Name number = %02Xh\n", net_num);
puts("Sending datagram...");
send_block -> NCB_STO = 0;
send_block -> NCB_BUFFER_OFFSET = send_message;
send_block -> NCB_BUFFER_SEGMENT = _DS;
send_block -> NCB_LENGTH = strlen(send_message);
strncpy(send_block -> NCB_CALLNAME, rcvr, 16);
send_block -> NCB_COMMAND = SEND_DATAGRAM_WAIT;
_ES = _DS;
_BX = send_block;
_AX = 0x100;
geninterrupt(0x5c);
ret_code = _AL;
if (ret_code)
printf("Error number = %02Xh\n", ret_code);
else
puts("Datagram sent successfully.");
printf("Releasing session >>>%s<<<, name number %02Xh\n",
send_block -> NCB_NAME, net_num);
send_block -> NCB_NUM = net_num;
send_block -> NCB_COMMAND = DELETE_NAME_WAIT;
_ES = _DS;
_BX = send_block;
_AX = 0x100;
geninterrupt(0x5c);
ret_code = _AL;
if (ret_code)
printf("Error number = %02Xh.\n", ret_code);
else
puts("Completed normally.");
}
Technical Details
Message-ID:
<8809290558.AA08928@jade.berkeley.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!husc6!bloom-beacon!gatech!ncar!ames!pasteur!ucbvax!cup.portal.COM!TRADERShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!husc6!bloom-beacon!gatech!ncar!ames!pasteur!ucbvax!cup.portal.COM!TRADER From: TRADER@cup.portal.COM Newsgroups: comp.protocols.ibm Subject: NBSEND2.C (needs NBRCV2.C) Message-ID: <8809290558.AA08928@jade.berkeley.edu> Date: 27 Sep 88 01:33:27 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: portal!cup.portal.com!TRADER@uunet.uu.net Organization: The Internet Lines: 99