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

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

?? icsdll1.cpp

?? . Info directory .delphiinternet Delphi sample applications (all Delphi versions) .cppinternet C++
?? 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:        http://www.overbyte.be       francois.piette@overbyte.be
              http://www.rtfm.be/fpiette   francois.piette@rtfm.be
              francois.piette@pophost.eunet.be
Support:      Use the mailing list twsocket@elists.org
              Follow "support" link at http://www.overbyte.be for subscription.
Legal issues: Copyright (C) 2000-2002 by Fran鏾is PIETTE
              Rue de Grady 24, 4053 Embourg, Belgium. Fax: +32-4-365.74.56
              <francois.piette@overbyte.be> <francois.piette@pophost.eunet.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一区二区三区免费野_久草精品视频
成人一区二区视频| 丝袜美腿高跟呻吟高潮一区| 国产乱人伦精品一区二区在线观看| 欧美电影在线免费观看| 午夜精品福利一区二区蜜股av| 欧美三级午夜理伦三级中视频| 亚洲成人午夜影院| 欧美成人猛片aaaaaaa| 国产一区二区三区四| 中文字幕不卡三区| 欧美在线免费视屏| 日本中文字幕一区二区视频 | 成人激情小说网站| 亚洲免费资源在线播放| 欧美午夜不卡视频| 精品制服美女久久| 亚洲色图在线视频| 91精品国产乱码| 欧美性受xxxx黑人xyx性爽| 婷婷国产在线综合| 久久亚洲影视婷婷| 91浏览器入口在线观看| 青青草国产成人99久久| 国产精品三级视频| 制服丝袜一区二区三区| 风间由美一区二区av101 | 正在播放亚洲一区| 国产精品99久| 亚洲va韩国va欧美va精品| 久久老女人爱爱| 欧美性淫爽ww久久久久无| 国产麻豆成人传媒免费观看| 亚洲私人黄色宅男| 精品免费一区二区三区| 色综合久久综合网97色综合| 精品午夜久久福利影院| 亚洲一区二区视频在线观看| 久久精品免费在线观看| 欧美夫妻性生活| 91小视频免费看| 国产在线精品一区二区夜色| 亚洲成人精品一区| 亚洲视频免费在线观看| 亚洲精品在线观看网站| 欧美日韩午夜影院| 成人免费看视频| 韩国精品在线观看| 日本欧美在线观看| 亚洲国产精品精华液网站| 中文字幕一区二区三区不卡| 2021中文字幕一区亚洲| 91精品久久久久久久99蜜桃| 91在线一区二区| 国产成人自拍在线| 九九精品视频在线看| 日本美女一区二区三区视频| 玉足女爽爽91| 亚洲精品老司机| 国产精品亲子乱子伦xxxx裸| 久久先锋影音av鲁色资源| 欧美一区二区三区喷汁尤物| 欧美日韩国产成人在线免费| 色婷婷精品久久二区二区蜜臀av| 福利电影一区二区| 粉嫩13p一区二区三区| 国产麻豆精品久久一二三| 久久99精品久久久| 美腿丝袜亚洲一区| 麻豆91小视频| 蜜臀av性久久久久蜜臀av麻豆| 亚洲高清在线视频| 日韩国产精品久久久| 日韩黄色免费电影| 日韩**一区毛片| 91国偷自产一区二区使用方法| jizz一区二区| 91碰在线视频| 欧美综合色免费| 欧美日韩一区 二区 三区 久久精品| 99国产精品久久久久| 91免费观看视频| 欧美在线播放高清精品| 精品视频一区三区九区| 欧美三级在线播放| 日韩一级欧美一级| 久久综合狠狠综合久久综合88 | 偷拍一区二区三区四区| 午夜一区二区三区在线观看| 亚洲综合av网| 免费人成网站在线观看欧美高清| 蜜臀av国产精品久久久久| 精品亚洲porn| caoporn国产一区二区| 色综合天天综合在线视频| 欧美在线免费播放| 日韩亚洲欧美中文三级| 欧美岛国在线观看| 欧美国产日韩精品免费观看| 亚洲免费观看在线视频| 午夜精品久久久久久久久| 精品一区二区免费视频| 岛国一区二区三区| 欧美性受xxxx| 精品国产精品网麻豆系列| 日本一区二区综合亚洲| 亚洲综合av网| 国产伦精品一区二区三区免费 | 久久亚洲精华国产精华液| 国产精品人妖ts系列视频| 午夜久久久久久| 国产经典欧美精品| 欧美在线不卡一区| 久久久美女毛片| 亚洲国产精品一区二区尤物区| 韩国中文字幕2020精品| 91久久线看在观草草青青 | 欧美一a一片一级一片| 日韩女优av电影| 国产精品一线二线三线精华| 91久久免费观看| 国产精品成人午夜| 性感美女极品91精品| 国产精品亚洲午夜一区二区三区| 色综合色狠狠综合色| 日韩女优av电影| 亚洲午夜在线视频| 成人在线综合网| 日韩一级黄色大片| 一区二区欧美在线观看| 国模娜娜一区二区三区| 欧美人与禽zozo性伦| 亚洲人成影院在线观看| 国产ts人妖一区二区| 欧美一二三区在线观看| 亚洲精品你懂的| 成人免费电影视频| 精品日韩99亚洲| 爽好多水快深点欧美视频| 色综合天天综合在线视频| 欧美激情中文字幕| 久久超碰97人人做人人爱| 欧美浪妇xxxx高跟鞋交| 亚洲免费av高清| 99精品国产99久久久久久白柏 | av午夜一区麻豆| 久久久精品人体av艺术| 青青草视频一区| 6080午夜不卡| 亚洲国产三级在线| 色婷婷综合久久久| 亚洲人成小说网站色在线 | 亚洲视频免费在线观看| 国产福利一区二区三区视频| 日韩午夜精品视频| 裸体在线国模精品偷拍| 9191国产精品| 亚洲国产成人91porn| 91激情五月电影| 一区二区三区精品| 在线观看亚洲精品视频| 伊人性伊人情综合网| 欧美自拍丝袜亚洲| 亚洲狠狠爱一区二区三区| 欧美亚洲高清一区| 亚洲午夜精品在线| 欧美精品在线一区二区三区| 日韩不卡一区二区三区| 日韩精品一区二区三区四区| 免费成人在线影院| 久久亚洲影视婷婷| 成人一区在线观看| 亚洲日本va午夜在线电影| 91免费观看在线| 亚洲一区二区三区四区在线观看| 在线免费一区三区| 亚洲电影中文字幕在线观看| 欧美麻豆精品久久久久久| 日韩高清不卡一区二区三区| 精品日韩在线观看| 国产不卡视频一区| 亚洲日本一区二区三区| 欧美日韩国产经典色站一区二区三区| 日韩精品一二三四| 精品国产一区二区三区久久久蜜月| 国内精品在线播放| 亚洲国产精品成人综合| 一本久道久久综合中文字幕| 亚洲高清视频中文字幕| 欧美一区二区免费| 成人精品一区二区三区四区| 一区二区三区蜜桃网| 在线不卡免费欧美| 国产另类ts人妖一区二区| 亚洲欧美乱综合| 日韩一区二区免费在线电影 | 一本到不卡精品视频在线观看| 亚洲综合免费观看高清完整版| 日韩欧美视频在线 | 欧美在线一区二区| 国内一区二区视频|