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

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

?? icsdll1.cpp

?? 包含常用Internet協議TCP,UDP、HTTP、FTP、Telnet等
?? CPP
字號:
/*---------------------------------------------------------------------------

Author:       Fran鏾is PIETTE
Creation:     April 08, 2000
Description:  This is a demo showing how to use a TWSocket component in a DLL.
              This demo must be used with ICS TcpSrv demo program as a server.
              The DLL is a client which connect to the server and send "time"
              command, then wait for the reply and return it in the buffer
              passed to the DLL.
              There is only one function exported from the DLL: IcsDllDemo.
              It takes four arguments: a pointer to the hostname to connect to,
              a pointer to the port, a pointer to a buffer and a pointer for
              buffer size. On entry buffer size must be initialised with the
              size of the actual buffer. On exit, it is filled with the
              actual reply size. The function's return value is the error code
              such as 10061 when the server is not running.
Version:      1.00
EMail:        francois.piette@pophost.eunet.be    francois.piette@swing.be
              francois.piette@rtfm.be             http://www.rtfm.be/fpiette
Support:      Use the mailing list twsocket@rtfm.be See website for details.
Legal issues: Copyright (C) 2000 by Fran鏾is PIETTE
              Rue de Grady 24, 4053 Embourg, Belgium. Fax: +32-4-365.74.56
              <francois.piette@pophost.eunet.be><francois.piette@swing.be>

              This software is provided 'as-is', without any express or
              implied warranty.  In no event will the author be held liable
              for any  damages arising from the use of this software.

              Permission is granted to anyone to use this software for any
              purpose, including commercial applications, and to alter it
              and redistribute it freely, subject to the following
              restrictions:

              1. The origin of this software must not be misrepresented,
                 you must not claim that you wrote the original software.
                 If you use this software in a product, an acknowledgment
                 in the product documentation would be appreciated but is
                 not required.

              2. Altered source versions must be plainly marked as such, and
                 must not be misrepresented as being the original software.

              3. This notice may not be removed or altered from any source
                 distribution.

              4. You must register this software by sending a picture postcard
                 to the author. Use a nice stamp and mention your name, street
                 address, EMail address and any comment you like to say.

History:


---------------------------------------------------------------------------*/
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
#pragma argsused
#include "WSocket.hpp"
//---------------------------------------------------------------------------
extern "C" __declspec(dllexport) int __stdcall IcsDllDemo(char *HostName,
                                                          char *Port,
                                                          char *Buffer,
                                                          int  *BufSize);
void StrToBuffer(char *Buffer, int *BufSize, char *Msg);
//---------------------------------------------------------------------------
// We use a workerthread to do the job.
// This will allows the DLL to be called by several processes simultaneously
class TClientThread : public TThread
{
private:
    TWSocket *FClientSocket;
    void __fastcall ClientWSocketDataAvailable(TObject *Sender, WORD Error);
    void __fastcall ClientWSocketSessionClosed(TObject *Sender, WORD Error);
    void __fastcall ClientWSocketSessionConnected(TObject *Sender, WORD Error);
protected:
    AnsiString FHostName;
    AnsiString FPort;
    int        *FErrorCode;
    BOOL       FBannerReceived;
    char       *FBuffer;
    int        *FBufSize;
    void __fastcall Execute();
public:
    __fastcall TClientThread();
    __fastcall ~TClientThread();
    __property char      *Buffer    = {read=FBuffer,    write=FBuffer};
    __property int       *BufSize   = {read=FBufSize,   write=FBufSize};
    __property int       *ErrorCode = {read=FErrorCode, write=FErrorCode};
    __property AnsiString HostName  = {read=FHostName,  write=FHostName};
    __property AnsiString Port      = {read=FPort,      write=FPort};
};
//---------------------------------------------------------------------------
// Create a new thread in the blocked state. This allow the user to register
// the client thread before it actually start working.
__fastcall TClientThread::TClientThread()
    : TThread(TRUE)
{
    FreeOnTerminate = TRUE;
}
//---------------------------------------------------------------------------
// Destroy the thread. Destroy the ClientWSocket if needed.
__fastcall TClientThread::~TClientThread()
{
    if (FClientSocket != NULL) {
         FClientSocket->~TWSocket();
         FClientSocket = NULL;
    }
}
//---------------------------------------------------------------------------
// This is the main thread routine. There is not much to do because TWSocket
// is event drive. So everythong to do is done inside an event handler,
// mostly the OnDataAvailable event handler which is triggered each time
// something is received.
void __fastcall TClientThread::Execute()
{
    try {
        // Create the client TWSocket. It is important to create it inside the
        // Execute method because it *must* be created by the thread. Otherwise
        // the messages sent by winsock would be processed in the main thread
        // context, effectively disabling multi-threading.
        FClientSocket                     = new TWSocket(NULL);
        FClientSocket->OnDataAvailable    = ClientWSocketDataAvailable;
        FClientSocket->OnSessionConnected = ClientWSocketSessionConnected;
        FClientSocket->OnSessionClosed    = ClientWSocketSessionClosed;
        FClientSocket->LineMode           = TRUE;
        FClientSocket->Addr               = FHostName;
        FClientSocket->Port               = FPort;
        FClientSocket->Proto              = "tcp";
        FClientSocket->Connect();

        // Message loop to handle TWSocket messages
        // The loop is exited when WM_QUIT message is received
        FClientSocket->MessageLoop();
    }
    catch (Exception &E)
    {
        AnsiString Buf;
        Buf = E.ClassName();
        Buf = Buf  + ": " + E.Message;
        *FErrorCode = -3;
        StrToBuffer(Buffer, BufSize, Buf.c_str());
    }

    // Returning from the Execute function effectively terminate the thread
}
//---------------------------------------------------------------------------
// This event handler is called when the client connection is established.
void __fastcall TClientThread::ClientWSocketSessionConnected(
    TObject *Sender, WORD Error)
{
    if (Error) {
        *FErrorCode = Error;
        StrToBuffer(Buffer, BufSize, "Connect failed");
        PostMessage(FClientSocket->Handle, WM_QUIT, 0, 0);
    }
}
//---------------------------------------------------------------------------
// This event handler is called when the client connection is closed.
void __fastcall TClientThread::ClientWSocketSessionClosed(
    TObject *Sender, WORD Error)
{
    PostMessage(FClientSocket->Handle, WM_QUIT, 0, 0);
}
//---------------------------------------------------------------------------
// This event handler is called when data has been received from server.
// Since this sample program use line mode, we comes here only when a
// complete line has been received.
void __fastcall TClientThread::ClientWSocketDataAvailable(
    TObject *Sender, WORD Error)
{
    AnsiString RcvBuffer;

    // Received the line
    RcvBuffer = FClientSocket->ReceiveStr();
    // Check if we already received the banner (message sent by server
    // as soon as we are connected.
    if (!FBannerReceived) {
        // We are just receiving the banner. Flag as received
        FBannerReceived = TRUE;
        // Then send the command to the server
        FClientSocket->SendStr("time\r\n");
    }
    else {
        // We already received then banner. So this must be the answer
        // to our command. Copy to the buffer, without trailling CR/LF
        // and without overflowing the given buffer
        if (RcvBuffer.Length() < *BufSize)
            *BufSize = RcvBuffer.Length() - 2;  // Remove CR/LF
        if (*BufSize > 0)
            memcpy(Buffer, RcvBuffer.data(), *BufSize);
        // Then just close the communication
        FClientSocket->CloseDelayed();
        *FErrorCode = 0;
    }
}
//---------------------------------------------------------------------------
// Copy a string to a buffer with overflow check.
void StrToBuffer(char *Buffer, int *BufSize, char *Msg)
{
    int Len;

    if ((Len = strlen(Msg)) < *BufSize)
        *BufSize = Len;
    if (*BufSize > 0)
        memcpy(Buffer, Msg, *BufSize);
}
//---------------------------------------------------------------------------
// This is the function exported from the DLL. It is intended to be called
// from the application using the DLL.
int __stdcall IcsDllDemo(
    char *HostName,
    char *Port,
    char *Buffer,
    int  *BufSize)
{
    TClientThread *WorkerThread;
    int           Result;

    try {
        Result = -1;
        // Create a new thread. It is created in sleeping state
        WorkerThread           = new TClientThread;
        // Then pass all parameters
        WorkerThread->Buffer    = Buffer;
        WorkerThread->BufSize   = BufSize;
        WorkerThread->ErrorCode = &Result;
        WorkerThread->HostName  = HostName;
        WorkerThread->Port      = Port;
        // Then let thread start his work
        WorkerThread->Resume();
        // And wait until it finishes
        WaitForSingleObject((void *)WorkerThread->Handle, INFINITE);
    }
    catch (Exception &E)
    {
        AnsiString Buf;
        Buf = E.ClassName();
        Buf = Buf + ": " + E.Message;
        Result = -2;
        StrToBuffer(Buffer, BufSize, Buf.c_str());
    }
    return(Result);
};
//---------------------------------------------------------------------------
// This function is called by Windows when the DLL is loaded/unloaded and
// each time a thread attach/detach from the DLL
BOOL WINAPI DllEntryPoint(
    HINSTANCE hinstDLL, DWORD fwdreason, LPVOID lpvReserved)
{
    switch (fwdreason) {
    case DLL_PROCESS_ATTACH:
        // Increment WSocket reference count. This will make sure winsock will
        // remains loaded. This is because there is no permanent TWSocket
        // component created.
        WSocketGCount++;
        // This will load winsock and call WSAStartup
        WSocketGetProc("");
        break;
    case DLL_PROCESS_DETACH:
        // Decrement WSocket reference count.
        WSocketGCount--;
        // If reference count goes to zero, then unload winsock.
        if (WSocketGCount <= 0) {
            WSocketUnloadWinsock();
            WSocketGCount = 0;
        }
        break;
    }
    return(1);
}
//---------------------------------------------------------------------------

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美精品1区2区3区| 成人小视频免费在线观看| 欧美午夜精品理论片a级按摩| 国产精品美女久久久久久久久久久 | 蜜臂av日日欢夜夜爽一区| 91香蕉视频黄| 亚洲电影第三页| 日韩欧美国产一二三区| 国产高清视频一区| 亚洲人成影院在线观看| 欧美视频在线播放| 亚洲国产三级在线| 日韩一区二区免费在线观看| 黑人巨大精品欧美黑白配亚洲| 国产女人水真多18毛片18精品视频| 成人h动漫精品一区二| 一区二区三区欧美日| 日韩一区二区三区免费观看| 国产激情视频一区二区在线观看 | 久久综合九色欧美综合狠狠| 国产精品一区二区男女羞羞无遮挡| 久久亚洲私人国产精品va媚药| av一本久道久久综合久久鬼色| 亚洲国产欧美在线人成| 久久理论电影网| 精品视频一区 二区 三区| 国产一区亚洲一区| 亚洲午夜久久久久久久久电影网| 欧美成人伊人久久综合网| 99久久er热在这里只有精品15 | 老司机午夜精品| 国产精品久久久久久妇女6080| 在线免费观看成人短视频| 精品亚洲成av人在线观看| 亚洲女厕所小便bbb| 久久一区二区三区国产精品| 欧美日韩精品一区二区三区四区| 国产一区二区视频在线| 亚洲一二三四区| 国产日韩欧美高清在线| 日韩视频免费观看高清完整版在线观看| av在线不卡观看免费观看| 蜜桃视频在线一区| 樱桃视频在线观看一区| 国产日韩欧美一区二区三区乱码| 欧美日韩国产美女| 一本色道久久加勒比精品 | 国产精品久久久久久久浪潮网站 | 成人免费的视频| 奇米精品一区二区三区在线观看 | 欧美精品久久久久久久久老牛影院| 懂色av一区二区夜夜嗨| 免费成人小视频| 午夜视频一区二区三区| 亚洲欧美日韩久久精品| 欧美国产在线观看| 久久亚洲一区二区三区明星换脸| 欧美福利电影网| 色婷婷综合久久久久中文一区二区 | 中文字幕五月欧美| 久久影音资源网| 欧美一二区视频| 在线电影国产精品| 欧美少妇性性性| 在线精品亚洲一区二区不卡| 91影院在线观看| 成人丝袜18视频在线观看| 蜜臀a∨国产成人精品| 日韩制服丝袜先锋影音| 亚洲国产精品一区二区www| 亚洲同性同志一二三专区| 国产精品乱子久久久久| 国产精品福利电影一区二区三区四区| 国产欧美一区二区精品久导航| 久久新电视剧免费观看| 欧美精品一区二区三区蜜桃视频 | 国产在线不卡一卡二卡三卡四卡| 免费亚洲电影在线| 蜜臀av性久久久久av蜜臀妖精| 麻豆国产欧美一区二区三区| 欧美aaaaa成人免费观看视频| 午夜成人在线视频| 蜜臀av一级做a爰片久久| 另类成人小视频在线| 国产一二精品视频| 不卡影院免费观看| 一本色道久久综合亚洲精品按摩| 欧美性色综合网| 制服丝袜国产精品| 精品国产一区二区三区不卡| 久久久国产精华| 亚洲情趣在线观看| 亚洲国产视频一区| 精品一区二区久久久| 国产成人av影院| 色哦色哦哦色天天综合| 欧美日韩国产色站一区二区三区| 欧美一级免费大片| 久久久电影一区二区三区| 国产精品久久久久久久第一福利| 一区二区三区波多野结衣在线观看| 午夜激情一区二区| 国产麻豆成人精品| 91在线观看视频| 欧美绝品在线观看成人午夜影视| 精品国产91洋老外米糕| 国产精品亲子乱子伦xxxx裸| 一区二区三区91| 精品无人码麻豆乱码1区2区| 成人妖精视频yjsp地址| 欧美日韩综合不卡| 国产亚洲精品福利| 亚洲成人av电影在线| 国模少妇一区二区三区| 不卡一卡二卡三乱码免费网站| 欧美午夜电影在线播放| 精品久久五月天| 一个色在线综合| 国产一区二区91| 欧美日韩亚洲综合一区| 国产亚洲精品精华液| 日日嗨av一区二区三区四区| 国产91丝袜在线观看| 欧美精品在线一区二区| 国产精品素人一区二区| 日本不卡一区二区三区高清视频| 成人在线综合网| 在线不卡免费av| 亚洲欧美自拍偷拍色图| 男人的j进女人的j一区| 91美女在线观看| 精品国产一区二区三区四区四| 亚洲免费三区一区二区| 国产精品资源网| 538prom精品视频线放| 中文字幕一区二区三区蜜月| 蜜臀av亚洲一区中文字幕| 91福利国产成人精品照片| 久久欧美一区二区| 视频一区视频二区在线观看| 99热国产精品| 久久新电视剧免费观看| 亚洲成人一区在线| 99re这里只有精品视频首页| 久久精品视频一区二区三区| 日韩精品成人一区二区在线| 96av麻豆蜜桃一区二区| 久久久国产精品麻豆| 精彩视频一区二区三区| 91精品国产91热久久久做人人 | 日韩精品久久理论片| 欧美色图在线观看| 亚洲四区在线观看| 丁香天五香天堂综合| 精品国产3级a| 久久精品国产77777蜜臀| 91精品国产手机| 亚洲国产另类精品专区| 欧美无砖专区一中文字| 亚洲欧美日韩系列| 色综合网色综合| 亚洲老妇xxxxxx| 色婷婷久久综合| 亚洲综合男人的天堂| 日本道精品一区二区三区| 亚洲三级在线播放| 在线亚洲人成电影网站色www| 中文字幕字幕中文在线中不卡视频| 国产高清亚洲一区| 国产精品久久午夜| 99久久精品免费看国产免费软件| 国产精品乱码妇女bbbb| 欧美综合一区二区| 亚洲国产精品一区二区www| 欧美日本一区二区三区四区| 亚洲国产精品人人做人人爽| 欧美性猛交xxxx乱大交退制版 | 91麻豆国产在线观看| 一区二区三区.www| 欧美久久久一区| 麻豆精品一区二区综合av| 亚洲精品一区二区三区精华液| 精品制服美女丁香| 国产欧美精品一区二区色综合朱莉| 国产成人aaaa| 亚洲色图视频网站| 欧美日本韩国一区二区三区视频| 天天影视涩香欲综合网| 精品少妇一区二区三区日产乱码| 国产一区二区三区黄视频| 国产精品久久久久久久久免费樱桃| 91在线你懂得| 日本在线不卡一区| 久久久不卡网国产精品一区| 色综合一区二区三区| 天天综合日日夜夜精品| 国产亚洲精品7777| 日本高清不卡一区| 久草热8精品视频在线观看| 亚洲国产激情av|