资源简介
WINDOWS网络编程技术(PDF)
代码片段和文件信息
// Module Name: Nbclient.c
//
// Purpose:
// This is a NetBIOS client application that can interact with
// either of the two server samples. The client attempts a
// connection to the server on all LANA numbers. Once the first
// connect succeeds all others are cancelled or disconnected.
//
// Compile:
// cl -o Nbclient.exe Nbclient.c ..\Common\Nbcommon.obj
// netapi32.lib user32.lib
//
// Command Line Options:
// Nbclient.exe CLIENT-NAME SERVER-NAME
//
// CLIENT-NAME The NetBIOS name this client registers as
// SERVER-NAME The NetBIOS name of the server to connect to
//
#include
#include
#include
#include “..\Common\nbcommon.h“
#define MAX_SESSIONS 254
#define MAX_NAMES 254
#define MAX_BUFFER 1024
char szServerName[NCBNAMSZ];
//
// Function: Connect
//
// Description:
// Post an asynchronous connect on the given LANA number to
// the server. The NCB structure passed in already has the
// ncb_event field set to a valid Windows event handle. Just
// fill in the blanks and make the call.
//
int Connect(PNCB pncb int lana char *server char *client)
{
pncb->ncb_command = NCBCALL | ASYNCH;
pncb->ncb_lana_num = lana;
memset(pncb->ncb_name ‘ ‘ NCBNAMSZ);
strncpy(pncb->ncb_name client strlen(client));
memset(pncb->ncb_callname ‘ ‘ NCBNAMSZ);
strncpy(pncb->ncb_callname server strlen(server));
if (Netbios(pncb) != NRC_GOODRET)
{
printf(“ERROR: Netbios: NCBCONNECT: %d\n“
pncb->ncb_retcode);
return pncb->ncb_retcode;
}
return NRC_GOODRET;
}
//
// Function: main
//
// Description:
// Initialize the NetBIOS interface allocate some resources
// (event handles a send buffer and so on) and issue an
// NCBCALL for each LANA to the given server. Once a connection
// has been made cancel or hang up any other outstanding
// connections. Then send/receive the data. Finally clean
// things up.
//
int main(int argc char **argv)
{
HANDLE *hArray;
NCB *pncb;
char szSendBuff[MAX_BUFFER];
DWORD dwBufferLen
dwRet
dwIndex
dwNum;
LANA_ENUM lenum;
int i;
if (argc != 3)
{
printf(“usage: nbclient CLIENT-NAME SERVER-NAME\n“);
return 1;
}
// Enumerate all LANAs and reset each one
//
if (LanaEnum(&lenum) != NRC_GOODRET)
return 1;
if (ResetAll(&lenum (UCHAR)MAX_SESSIONS (UCHAR)MAX_NAMES
FALSE) != NRC_GOODRET)
return 1;
strcpy(szServerName argv[2]);
//
// Allocate an array of HANDLEs to use for asynchronous events.
// Also allocate an array of NCB structures. We need 1 handle
// and 1 NCB for each LANA number.
//
hArray = (HANDLE *)GlobalAlloc(GMEM_FIX
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1688792 2000-10-26 23:51 WINDOWS网络编程技术(PDF)\001.PDF
文件 325212 2000-10-26 23:51 WINDOWS网络编程技术(PDF)\002.PDF
文件 453893 2000-10-26 23:51 WINDOWS网络编程技术(PDF)\003.PDF
文件 959840 2000-10-26 23:51 WINDOWS网络编程技术(PDF)\004.PDF
文件 470599 2000-10-26 23:51 WINDOWS网络编程技术(PDF)\005.PDF
文件 1205325 2000-10-26 23:51 WINDOWS网络编程技术(PDF)\006.PDF
文件 1564568 2000-10-26 23:51 WINDOWS网络编程技术(PDF)\007.PDF
文件 1237327 2000-10-26 23:51 WINDOWS网络编程技术(PDF)\008.PDF
文件 1224720 2000-10-26 23:51 WINDOWS网络编程技术(PDF)\009.PDF
文件 685433 2000-10-26 23:51 WINDOWS网络编程技术(PDF)\010.PDF
文件 1176145 2000-10-26 23:51 WINDOWS网络编程技术(PDF)\011.PDF
文件 1886742 2000-10-26 23:51 WINDOWS网络编程技术(PDF)\012.PDF
文件 904412 2000-10-26 23:51 WINDOWS网络编程技术(PDF)\013.PDF
文件 1204931 2000-10-26 23:51 WINDOWS网络编程技术(PDF)\014.PDF
文件 1092155 2000-10-26 23:51 WINDOWS网络编程技术(PDF)\015.PDF
文件 941192 2000-10-26 23:51 WINDOWS网络编程技术(PDF)\016.PDF
文件 340887 2000-10-26 23:51 WINDOWS网络编程技术(PDF)\017.PDF
文件 567525 2000-10-26 23:51 WINDOWS网络编程技术(PDF)\018.PDF
文件 189458 2000-10-26 23:51 WINDOWS网络编程技术(PDF)\019.PDF
文件 18138 1998-05-28 21:43 WINDOWS网络编程技术(PDF)\源码\AppendixB\iparp\IPArp.Cpp
文件 20480 1999-06-25 18:57 WINDOWS网络编程技术(PDF)\源码\AppendixB\iparp\IpArp.exe
文件 957 1998-05-28 21:43 WINDOWS网络编程技术(PDF)\源码\AppendixB\iparp\IPArp.h
文件 472 1998-05-28 21:43 WINDOWS网络编程技术(PDF)\源码\AppendixB\iparp\Makefile
文件 7108 1998-05-28 21:55 WINDOWS网络编程技术(PDF)\源码\AppendixB\ipchange\IPChange.Cpp
文件 32768 1999-06-25 18:59 WINDOWS网络编程技术(PDF)\源码\AppendixB\ipchange\ipchange.exe
文件 490 1998-05-28 21:55 WINDOWS网络编程技术(PDF)\源码\AppendixB\ipchange\Makefile
文件 7059 1998-05-28 21:56 WINDOWS网络编程技术(PDF)\源码\AppendixB\ipconfig\IPConfig.Cpp
文件 36864 1999-06-25 19:01 WINDOWS网络编程技术(PDF)\源码\AppendixB\ipconfig\ipconfig.exe
文件 490 1998-05-28 21:56 WINDOWS网络编程技术(PDF)\源码\AppendixB\ipconfig\Makefile
文件 6184 1998-05-28 21:57 WINDOWS网络编程技术(PDF)\源码\AppendixB\iprenew\IPRenew.Cpp
............此处省略493个文件信息
评论
共有 条评论