亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? rnrcs.c

?? 《Windows網絡編程技術》附書源碼源碼. 運行環境:9x/Me/NT/2000/XP/ 源碼語言:簡體中文 第十四章
?? C
?? 第 1 頁 / 共 2 頁
字號:
// Module: rnrcs.c
//
// Description:
//    This sample illustrates how a server can create a socket and
//    advertise the existance of the service to clients.  It also
//    shows how a client with knowledge of the server's name only
//    can find out how to connect to the server in order to transmit
//    data. The server accomplishes this by installing a service
//    class which describes the basic characteristics of the service
//    and then registering an instance of the server which references
//    the given class. The service can be registered for multiple
//    name spaces such as IPX and NTDS.
//
//    The client can query the available name spaces for knowledge
//    of a service of the given name. If the query completes 
//    successfully, the address of the service is returned.  All
//    the client needs to do is use that address in either a
//    connect or sendto call.
//
// Compile:
//     cl rnrcs.c ws2_32.lib user32.lib ole32.lib
//
// Command Line Arguments/Parameters
//     rnrcs -c:ServiceName -s:ServiceName -t:ID -n:NameSpace
//       -c:ServiceName      Act as client and query for this service name
//       -s:ServiceName      Act as server and register service as this name
//       -t:ID               SAP ID to register under
//       -n:NameSpace        Name space to register service under
//                             Supported namespaces are NS_ALL, NS_SAP, NS_NTDS
//       -d                  Delete the service if found
//

#include <winsock2.h>
#include <windows.h>

#include <ws2tcpip.h>
#include <nspapi.h>

#include <svcguid.h>

#include "mynsp.h"

#include <stdio.h>
#include <stdlib.h>

#define MAX_NUM_CSADDRS        20
#define MAX_INTERFACE_LIST     20
#define MAX_NUM_SOCKETS        20

#define MAX_BUFFER_SZ         512

#define MAX_SERVER_NAME_SZ     64

#define DEFAULT_SERVER_NAME    "JunkServer"

char    szServerName[MAX_SERVER_NAME_SZ];   // Server name
BOOL    bServer,                            // Client or server?
        bDeleteService;
DWORD   dwUniqueId;                         // Used to create a GUID
SOCKET  sock;

//
// Function: usage
//
// Description:
//    Print usage information.
//
void usage(char *progname)
{
    printf("usage: %s  -c:Service -s  -t:ID\n",
        progname);
    printf("  -c:ServiceName Act as client and query for this service name\n");
    printf("  -s:ServiceName Act as server and register service as this name\n");
    printf("  -t:ID          Unique ID to register under\n");
    printf("  -d             Delete the service on a successful query\n");
    ExitProcess(-1);
}

//
// Function: ValidateArgs
//
// Description:
//    Parse command line parameters and set some global variables used
//    by the application.
//
void ValidateArgs(int argc, char **argv)
{
    int    i;

    // Set some default values
    //
    lstrcpy(szServerName, TEXT(DEFAULT_SERVER_NAME));
    dwUniqueId = 200;
    bDeleteService = FALSE;

    for (i=1; i < argc ;i++) 
    {
        if ((argv[i][0] == '-') || (argv[i][0] == '/')) 
        {
            switch (tolower(argv[i][1])) 
            {
                case 't':        // SAP id used to generate GUID
                    //if (lstrlen(argv[i]) > 3)
                    //    dwUniqueId = atoi(&argv[i][3]);
                    break;
                case 'c':        // Client, query for given service
                    bServer = FALSE;
                    if (lstrlen(argv[i]) > 3)
                        lstrcpy(szServerName, &argv[i][3]);
                    break;
                case 's':        // Server, register as the given service
                    bServer = TRUE;
                    if (lstrlen(argv[i]) > 3)
                        lstrcpy(szServerName, &argv[i][3]);
                    break;
                case 'd':
                    bDeleteService = TRUE;
                    break;
                default:
                    usage(argv[0]);
                    return;
            }
        }
        else
            usage(argv[0]);
    }
    return;
}

//
// Function: EnumNameSpaceProviders
//
// Description:
//    Returns an array of those name spaces which our application
//    supports. If one day, NS_DNS becomes dynamic, modify this
//    function to return that structure as well. 
//
WSANAMESPACE_INFO *EnumNameSpaceProviders(int *count)
{
    WSANAMESPACE_INFO *nsinfo,
                      *nsinfocpy;
    BYTE              *pbuf=NULL,
                      *pbufcpy=NULL;
    DWORD              dwBytes;
    int                i, j,
                       ret;

    *count = 0;
    dwBytes = 0;
    //
    // First find out how big of a buffer we need
    //
    ret = WSAEnumNameSpaceProviders(&dwBytes, NULL);
    if (ret == SOCKET_ERROR)
    {
        if (WSAGetLastError() != WSAEFAULT)
        {
            printf("WSAEnumNameSpaceProviders() failed: %d\n",
                WSAGetLastError());
            return NULL;
        }
    }
    // Allocate this buffer and call the function again
    //
    pbuf = (BYTE *)GlobalAlloc(GPTR, dwBytes);
    if (!pbuf)
    {
        printf("GlobaAlloc() failed: %d\n", GetLastError());
        return NULL;
    }
    nsinfo = (WSANAMESPACE_INFO *)pbuf;
    ret = WSAEnumNameSpaceProviders(&dwBytes, nsinfo);
    if (ret == SOCKET_ERROR)
    {
        printf("WSAEnumNameSpaceProviders() failed: %d\n",
            WSAGetLastError());
        HeapFree(GetProcessHeap(), 0, pbuf);
        return NULL;
    }
    // Make a copy buffer which we will return our data in
    //
    pbufcpy = GlobalAlloc(GPTR, dwBytes);
    if (!pbufcpy)
    {
        printf("GlobaAlloc() failed: %d\n", GetLastError());
        return NULL;
    }
    // Loop throug the returned name space structures picking
    // those which our app supports
    //
    nsinfocpy = (WSANAMESPACE_INFO *)pbufcpy;
    printf("%d name spaces are available\n", ret);

    j = 0;
    for(i=0; i < ret ;i++)
    {
        switch (nsinfo[i].dwNameSpace)
        {
            // In this example all we want is our own name space 
            //
            case NS_MYNSP:
                printf("Found a match: %S\n", nsinfo[i].lpszIdentifier); 
                memcpy(&nsinfocpy[j++], &nsinfo[i], sizeof(WSANAMESPACE_INFO));
                break;
	    default:
		break;
        }
    }
    // Free the original buffer and return our copy of useable name spaces
    //
    GlobalFree(pbuf);

    printf("Found %d useable name spaces\n\n", j);

    *count = j;
    return nsinfocpy;
}

//
// Function: InstallServiceClass
//
// Description:
//    This function installs the service class which is required before
//    registering an instance of a service. A service class defines the
//    generic attributes of a class of services such as whether it is
//    connection oriented or not as well as what protocols is supports
//    (IPX, IP, etc).
//
BOOL InstallServiceClass(GUID *svcguid, WSANAMESPACE_INFO *nsinfo, int nscount)
{
    WSASERVICECLASSINFO  sci;
    WSANSCLASSINFO      *nsclass=NULL;
    DWORD                dwOne=1;
    TCHAR                szServiceClassName[64];
    int                  i,
                         ret;
    BOOL                 bRet;

    bRet = TRUE;
    //
    // Generate a name of our service class
    //
    wsprintf(szServiceClassName, TEXT("Service Class/TCP Port: %003d"), dwUniqueId);
    printf("Installing service class: '%s'\n", szServiceClassName);
    //
    // There are 2 attributes we need to set for every name space
    // we want to register in: Connection Oriented/Connectionless as
    // well as the address family of the protocols we support.
    //
    nsclass = GlobalAlloc(GPTR, sizeof(WSANSCLASSINFO) * nscount * 2);
    if (!nsclass)
    {
        printf("GlobalAlloc() failed: %d\n", GetLastError());
        return FALSE;
    }
    // Initialize the structure
    //
    memset(&sci, 0, sizeof(sci));
    sci.lpServiceClassId = svcguid;
    sci.lpszServiceClassName = szServiceClassName;
    sci.dwCount = nscount * 2;
    sci.lpClassInfos = nsclass;

    printf("Namespace count: %d, Namespace: %d\n", nscount, nsinfo[0].dwNameSpace);
    for(i=0; i < nscount ;i++)
    {
        // No matter what name space we use we set the connection
        // oriented attribute to false (i.e. connectionless)
        //
        nsclass[i*2].lpszName = SERVICE_TYPE_VALUE_CONN;
        nsclass[i*2].dwNameSpace = nsinfo[i].dwNameSpace;
        nsclass[i*2].dwValueType = REG_DWORD;
        nsclass[i*2].dwValueSize = sizeof(DWORD);
        nsclass[i*2].lpValue = &dwOne;

        if (nsinfo[i].dwNameSpace == NS_MYNSP)
        {
            // If NS_MYNSP is available we will be running a UDP
            // based service on the given port number
            //
            printf("Setting NS_MYNSP info...\n");
            nsclass[(i*2)+1].lpszName = SERVICE_TYPE_VALUE_TCPPORT;
            nsclass[(i*2)+1].dwNameSpace = nsinfo[i].dwNameSpace;
            nsclass[(i*2)+1].dwValueType = REG_DWORD;
            nsclass[(i*2)+1].dwValueSize = sizeof(DWORD);
            nsclass[(i*2)+1].lpValue = &dwUniqueId;            
        }
    }
    // Install the service class
    //
    ret = WSAInstallServiceClass(&sci);
    if (ret == SOCKET_ERROR)
    {
        if (WSAGetLastError() == WSAEALREADY)
        {
            printf("Service class already registered\n");
            bRet = TRUE;
        }
        else
        {
            printf("WSAInstallServiceClass() failed: %d\n",
                WSAGetLastError());
            bRet = FALSE;
        }
    }
    GlobalFree(nsclass);

    return bRet;
}

//
// Function: GetIPInterfaceList
//
// Description:
//    This function returns an array of SOCKADDR_IN structures,
//    one for every local IP interface on the machine. We use
//    the ioctl command SIO_GET_INTERFACE_LIST to do this although
//    we could have used any number of method such as gethostbyname(),
//    SIO_INTERFACE_LIST_QUERY, or the IP helper APIs.
//
SOCKADDR_IN *GetIPInterfaceList(SOCKET s, int *count)
{
    static SOCKADDR_IN  sa_in[MAX_NUM_CSADDRS];

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人三级在线视频| 亚洲青青青在线视频| 国产精品国产三级国产| 亚洲综合无码一区二区| 麻豆精品一区二区av白丝在线| 国产高清不卡一区| 91蜜桃在线观看| 精品蜜桃在线看| 亚洲老妇xxxxxx| 久国产精品韩国三级视频| 91亚洲精品乱码久久久久久蜜桃| 欧美片在线播放| 国产日韩v精品一区二区| 亚洲一区二区三区四区中文字幕| 精品一二三四区| 色偷偷久久人人79超碰人人澡| 精品日产卡一卡二卡麻豆| 亚洲免费电影在线| 国产在线一区观看| 欧美三级日韩三级国产三级| 久久久综合网站| 亚洲国产三级在线| 白白色 亚洲乱淫| 日韩欧美三级在线| 一区二区三区小说| 国产一区二区调教| 欧美日本乱大交xxxxx| 国产性做久久久久久| 三级一区在线视频先锋 | 91麻豆精品国产91久久久更新时间 | 国产精品丝袜黑色高跟| 成人性视频网站| 欧美精品第1页| 亚洲六月丁香色婷婷综合久久 | 久久久亚洲国产美女国产盗摄 | 日韩一级大片在线| 亚洲欧美一区二区久久| 国产在线一区二区| 欧美精品在线一区二区三区| 亚洲视频在线一区观看| 国产一区二区三区观看| 777午夜精品免费视频| 久久久精品免费免费| 免费人成黄页网站在线一区二区| 91久久线看在观草草青青| 中文字幕av不卡| 久久国产欧美日韩精品| 69堂国产成人免费视频| 亚洲成av人片一区二区梦乃| 色爱区综合激月婷婷| 中文文精品字幕一区二区| 久久成人久久爱| 欧美精品自拍偷拍动漫精品| 洋洋成人永久网站入口| 99久久久免费精品国产一区二区| 久久毛片高清国产| 免费成人深夜小野草| 正在播放一区二区| 亚洲成av人片一区二区| 欧美视频在线一区| 一区二区三区日韩在线观看| 99精品视频在线播放观看| 中文字幕欧美日韩一区| 国产精品资源网站| 久久蜜桃av一区精品变态类天堂| 国产呦精品一区二区三区网站 | a美女胸又www黄视频久久| 欧美性猛交xxxxxxxx| 亚洲精品国产第一综合99久久 | 中文字幕字幕中文在线中不卡视频| 国产成人免费视频网站| 久久亚区不卡日本| 国产乱人伦偷精品视频免下载| 欧美一三区三区四区免费在线看 | 日韩欧美成人激情| 免费成人性网站| 欧美va在线播放| 另类小说图片综合网| 欧美精品一区男女天堂| 国产精品综合久久| 国产欧美一区二区精品性| 丁香网亚洲国际| 1区2区3区国产精品| 在线亚洲一区二区| 亚洲国产视频一区| 欧美一区二区免费视频| 精油按摩中文字幕久久| 亚洲国产一区在线观看| 91福利视频久久久久| 夜夜操天天操亚洲| 91麻豆精品国产91久久久资源速度| 蜜臀av一区二区在线观看| 精品国产91久久久久久久妲己 | 精品国产一区二区三区久久久蜜月 | 成人免费视频一区| 国产精品美女久久久久久久网站| 91麻豆免费观看| 亚洲国产精品麻豆| 欧美xxxxx裸体时装秀| 国产91丝袜在线观看| 亚洲色图视频网站| 欧美伦理影视网| 韩国精品在线观看| 中文字幕一区二区不卡 | 视频一区二区不卡| 久久九九影视网| 一本色道亚洲精品aⅴ| 天天操天天色综合| 久久色中文字幕| 一本在线高清不卡dvd| 日本va欧美va瓶| 国产精品欧美综合在线| 欧美日韩黄色一区二区| 韩国一区二区三区| 亚洲免费在线看| 3d动漫精品啪啪一区二区竹菊 | 国产亚洲欧美在线| 色八戒一区二区三区| 蜜臀99久久精品久久久久久软件| 国产清纯白嫩初高生在线观看91| 欧美性感一类影片在线播放| 久久99精品久久久久久 | 在线视频综合导航| 国产一区二区三区免费播放| 一二三四社区欧美黄| 精品国产一二三区| 色婷婷av久久久久久久| 久久99精品久久久久| 亚洲精品videosex极品| 久久综合九色综合97婷婷女人| 色综合久久天天| 国产在线播精品第三| 香蕉久久夜色精品国产使用方法 | 成人av在线播放网站| 日韩精品成人一区二区三区| 亚洲欧洲日韩一区二区三区| 精品久久久久久综合日本欧美| 色婷婷久久久久swag精品 | 中文字幕第一区综合| 91精品国产色综合久久不卡电影 | 国产精品欧美久久久久无广告 | 经典三级一区二区| 亚洲与欧洲av电影| 中文字幕不卡在线观看| 欧美一区二区私人影院日本| 91蝌蚪porny| 国产丶欧美丶日本不卡视频| 裸体健美xxxx欧美裸体表演| 国产99久久久精品| 免费看精品久久片| 亚洲大片在线观看| 亚洲欧美日韩国产中文在线| 国产欧美日韩亚州综合| 欧美成人激情免费网| 欧美精品日日鲁夜夜添| 91丨九色丨尤物| 国产成人a级片| 精品写真视频在线观看| 日本欧美大码aⅴ在线播放| 一级中文字幕一区二区| 亚洲人成网站精品片在线观看| 国产欧美一区二区三区沐欲| 精品国产网站在线观看| 日韩视频在线你懂得| 欧美乱妇15p| 欧美亚洲国产一区二区三区va | 亚洲同性gay激情无套| 国产喷白浆一区二区三区| 精品久久久久久无| 日韩欧美三级在线| 日韩三级av在线播放| 777久久久精品| 欧美久久久久久久久| 欧美优质美女网站| 91网页版在线| 91浏览器打开| 91福利在线导航| 欧美日韩在线观看一区二区| 欧美综合一区二区| 欧美亚洲国产一区二区三区va| 欧洲精品视频在线观看| 欧美视频中文一区二区三区在线观看| 91高清在线观看| 欧美亚洲综合网| 欧美日韩高清一区二区不卡 | 麻豆国产91在线播放| 麻豆精品一区二区| 国产在线视视频有精品| 国产一区二区三区四区在线观看| 国产一区二区三区四| 国产91丝袜在线18| 99久久国产综合色|国产精品| 99r国产精品| 欧美日韩免费观看一区二区三区| 欧美丝袜丝交足nylons图片| 在线不卡中文字幕播放| 欧美大片一区二区三区| 国产丝袜美腿一区二区三区| 中文字幕精品一区二区精品绿巨人 | 久久狠狠亚洲综合|