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

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

?? tcpsrv1.cpp

?? 基于互聯網的GPRS模塊交換代碼
?? CPP
字號:
/*---------------------------------------------------------------------------

Author:       Fran鏾is Piette
Creation:     Sep 05, 1999 (From Delphi version dated aug 29, 1999)
Version:      1.00
Description:  Basic TCP server showing how to use TWSocketServer and
              TWSocketClient components.
EMail:        francois.piette@swing.be          http://www.rtfm.be/fpiette
              francois.piette@pophost.eunet.be  francois.piette@rtfm.be
Support:      Use the mailing list twsocket@rtfm.be See website for details.
Legal issues: Copyright (C) 1999-2000 by Fran鏾is PIETTE
              Rue de Grady 24, 4053 Embourg, Belgium. Fax: +32-4-365.74.56
              <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:

---------------------------------------------------------------------------*/
#if __BORLANDC__ == 0x520     // BCB1 is BC5.20   BCB3 is BC5.30
    #define _WINSOCKAPI_      // Prevent winsock.h from being included
    #define s_addr S_addr
#endif
#include <vcl.h>
#include <vcl\inifiles.hpp>
#pragma hdrstop

#include "TcpSrv1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "WSocket"
#pragma link "WSocketS"
#pragma resource "*.dfm"
#define SectionWindow      "WindowTcpSrv"
#define KeyTop             "Top"
#define KeyLeft            "Left"
#define KeyWidth           "Width"
#define KeyHeight          "Height"
TTcpSrvForm *TcpSrvForm;
//---------------------------------------------------------------------------
__fastcall TTcpSrvForm::TTcpSrvForm(TComponent* Owner)
    : TForm(Owner)
{
    // Build Ini file name
    FIniFileName = LowerCase(ExtractFileName(Application->ExeName));
    FIniFileName = FIniFileName.SubString(1, FIniFileName.Length() - 3) + "ini";
}
//---------------------------------------------------------------------------
void __fastcall TTcpSrvForm::FormShow(TObject *Sender)
{
    TIniFile    *IniFile;

    if (!FInitialized) {
        FInitialized     = TRUE;
        IniFile          = new TIniFile(FIniFileName);
        Top              = IniFile->ReadInteger(SectionWindow, KeyTop,    Top);
        Left             = IniFile->ReadInteger(SectionWindow, KeyLeft,   Left);
        Width            = IniFile->ReadInteger(SectionWindow, KeyWidth,  Width);
        Height           = IniFile->ReadInteger(SectionWindow, KeyHeight, Height);
        delete IniFile;
        DisplayMemo->Clear();
        // Delay startup code until our UI is ready and visible
        PostMessage(Handle, WM_APPSTARTUP, 0, 0);
    }
}
//---------------------------------------------------------------------------
void __fastcall TTcpSrvForm::FormClose(TObject *Sender, TCloseAction &Action)
{
    TIniFile *IniFile;

    IniFile = new TIniFile(FIniFileName);
    IniFile->WriteInteger(SectionWindow, KeyTop,    Top);
    IniFile->WriteInteger(SectionWindow, KeyLeft,   Left);
    IniFile->WriteInteger(SectionWindow, KeyWidth,  Width);
    IniFile->WriteInteger(SectionWindow, KeyHeight, Height);
    delete IniFile;
}
//---------------------------------------------------------------------------
// Display a message in our display memo. Delete lines to be sure to not
// overflow the memo which may have a limited capacity.
void __fastcall TTcpSrvForm::Display(AnsiString Msg)
{
    int I;

    DisplayMemo->Lines->BeginUpdate();
    if (DisplayMemo->Lines->Count > 200) {
        for (I = 1; I <= 50; I++)
            DisplayMemo->Lines->Delete(0);
    }
    DisplayMemo->Lines->Add(Msg);
    DisplayMemo->Lines->EndUpdate();
}
//---------------------------------------------------------------------------
// This is our custom message handler. We posted a WM_APPSTARTUP message
// from FormShow event handler. Now UI is ready and visible.
void __fastcall TTcpSrvForm::WMAppStartup(TMessage Message)
{
    WSocketServer1->Proto       = "tcp";         // Use TCP protocol
    WSocketServer1->Port        = "telnet";      // Use telnet port
    WSocketServer1->Addr        = "0.0.0.0";     // Use any interface
    WSocketServer1->ClientClass = __classid(TTcpSrvClient); // Use our component
    WSocketServer1->Listen();                    // Start litening
    Display("Waiting for clients...");
}
//---------------------------------------------------------------------------
void __fastcall TTcpSrvForm::WSocketServer1ClientConnect(TObject *Sender,
      TWSocketClient *Client, WORD Error)
{
    Display("Client connecting: " + ((TTcpSrvClient *)Client)->PeerAddr);
    ((TTcpSrvClient *)Client)->LineMode        = TRUE;
    ((TTcpSrvClient *)Client)->LineEdit        = TRUE;
    ((TTcpSrvClient *)Client)->OnDataAvailable = ClientDataAvailable;
    ((TTcpSrvClient *)Client)->OnBgException   = ClientBgException;
    ((TTcpSrvClient *)Client)->ConnectTime     = Now();
}
//---------------------------------------------------------------------------
void __fastcall TTcpSrvForm::WSocketServer1ClientDisconnect(TObject *Sender,
      TWSocketClient *Client, WORD Error)
{
    Display("Client disconnecting: " + ((TTcpSrvClient *)Client)->PeerAddr + "    " +
            "Duration: " + FormatDateTime("hh:nn:ss",
            Now() - ((TTcpSrvClient *)Client)->ConnectTime));
}
//---------------------------------------------------------------------------
void __fastcall TTcpSrvForm::ClientDataAvailable(TObject *Sender, WORD Error)
{
    TTcpSrvClient *Client;

    Client = (TTcpSrvClient *)Sender;

    // We use line mode. We will receive complete lines
    Client->RcvdLine = Client->ReceiveStr();
    // Remove trailing CR/LF
    while ((Client->RcvdLine.Length() > 0) &&
           ((Client->RcvdLine[Client->RcvdLine.Length()] == '\r') ||
            (Client->RcvdLine[Client->RcvdLine.Length()] == '\n'))) {
        Client->RcvdLine = Client->RcvdLine.SubString(1, Client->RcvdLine.Length() - 1);
    }
    Display("Received from " + Client->PeerAddr + ": '" + Client->RcvdLine + "'");
    ProcessData(Client);
}
//---------------------------------------------------------------------------
void __fastcall TTcpSrvForm::ProcessData(TTcpSrvClient *Client)
{
    int           I;
    TTcpSrvClient *AClient;

    // We could replace all those CompareText with a table lookup 
    if (CompareText(Client->RcvdLine, "exit") == 0)
        // We can't call Client.Close here because we will immediately
        // reenter DataAvailable event handler with same line because
        // a line is removed from buffer AFTER it has been processed.
        // Using CloseDelayed will delay Close until we are out of
        // current event handler.
        Client->CloseDelayed();
    else if (CompareText(Client->RcvdLine, "time") == 0)
        // Send server date and time to client
        Client->SendStr(DateTimeToStr(Now()) + "\r\n");
    else if (CompareText(Client->RcvdLine, "who") == 0) {
        // Send client list to client
        Client->SendStr("There are " + IntToStr(WSocketServer1->ClientCount) +
                        " connected users:\r\n");
        for (I = WSocketServer1->ClientCount - 1; I >= 0; I--) {
            AClient = (TTcpSrvClient *)(WSocketServer1->Client[I]);
            Client->SendStr(AClient->PeerAddr + ":" + AClient->PeerPort + " " +
                           DateTimeToStr(AClient->ConnectTime) + "\r\n");
        }
    }
    else if (CompareText(Client->RcvdLine, "exception") == 0)
        // This will trigger a background exception for client
        PostMessage(Client->Handle, WM_TRIGGER_EXCEPTION, 0, 0);
    else
        Client->SendStr("Unknown command: '" + Client->RcvdLine + "'\r\n");
}
//---------------------------------------------------------------------------
// This event handler is called when listening (server) socket experienced
// a background exception. Should normally never occurs.
void __fastcall TTcpSrvForm::WSocketServer1BgException(TObject *Sender,
      Exception *E, bool &CanClose)
{
    Display("Server exception occured: " + E->ClassName() + ": " + E->Message);
    CanClose = FALSE;  // Hoping that server will still work !
}
//---------------------------------------------------------------------------
// This event handler is called when a client socket experience a background
// exception. It is likely to occurs when client aborted connection and data
// has not been sent yet.
void __fastcall TTcpSrvForm::ClientBgException(TObject   *Sender,
                                          Exception *E,
                                          bool      &CanClose)
{
    Display("Client exception occured: " + E->ClassName() + ": " + E->Message);
    CanClose = TRUE;   // Goodbye client !
}
//---------------------------------------------------------------------------
__fastcall TTcpSrvClient::TTcpSrvClient(TComponent* Owner)
    : TWSocketClient(Owner)
{
}
//---------------------------------------------------------------------------

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美在线不卡| 久久精品在这里| 极品少妇一区二区三区精品视频| 国产欧美精品一区aⅴ影院 | 在线观看亚洲精品| 伦理电影国产精品| 中文字幕五月欧美| 欧美刺激午夜性久久久久久久| av资源站一区| 美脚の诱脚舐め脚责91 | 亚洲黄色av一区| 久久影视一区二区| 欧美午夜精品久久久| 国产成人免费视| 日本午夜一本久久久综合| 一色屋精品亚洲香蕉网站| 精品国产精品一区二区夜夜嗨| 色综合欧美在线视频区| 国产美女娇喘av呻吟久久| 香港成人在线视频| 国产精品精品国产色婷婷| 欧美电视剧免费全集观看 | 日韩毛片高清在线播放| 精品久久人人做人人爱| 欧美性猛交一区二区三区精品| 成人综合在线网站| 久久 天天综合| 午夜av一区二区三区| 中文字幕在线一区免费| 久久久国产精品不卡| 日韩欧美一二三| 欧美精品在线一区二区三区| 91猫先生在线| 成人免费三级在线| 国产激情视频一区二区三区欧美 | 秋霞av亚洲一区二区三| 亚洲激情综合网| 国产精品久99| 国产精品全国免费观看高清| 337p日本欧洲亚洲大胆精品| 日韩视频一区二区三区在线播放 | 久久精品男人的天堂| 日韩区在线观看| 欧美一区二区私人影院日本| 欧美老年两性高潮| 欧美卡1卡2卡| 欧美精品一二三区| 欧美男人的天堂一二区| 欧美日韩第一区日日骚| 欧美久久久一区| 制服丝袜国产精品| 欧美一卡在线观看| 日韩你懂的电影在线观看| 91精品国产欧美日韩| 91精品福利在线一区二区三区| 欧美丰满一区二区免费视频 | 精品国产91亚洲一区二区三区婷婷| 欧美日韩另类一区| 91精品国产手机| 精品乱人伦一区二区三区| 欧美岛国在线观看| 久久精品欧美一区二区三区麻豆| 日本一区二区久久| 亚洲另类中文字| 亚洲成人自拍一区| 美洲天堂一区二卡三卡四卡视频| 美女精品自拍一二三四| 国产一区不卡在线| 成人污污视频在线观看| 91原创在线视频| 欧美伊人精品成人久久综合97| 欧美精品1区2区| 精品福利av导航| 国产精品免费丝袜| 亚洲大片精品永久免费| 美女看a上一区| 成人自拍视频在线观看| 色噜噜狠狠成人中文综合| 欧美喷潮久久久xxxxx| 日韩精品资源二区在线| 国产亚洲污的网站| 亚洲欧美日韩国产综合在线| 亚洲成人高清在线| 韩国成人精品a∨在线观看| 成人一级片网址| 91网址在线看| 欧美一区二区三区人| 久久久久久久久久看片| 亚洲人成精品久久久久| 日韩精品午夜视频| 国产99久久久精品| 欧美视频一区二区三区四区| 日韩欧美电影在线| 亚洲免费三区一区二区| 蜜桃在线一区二区三区| 成人avav影音| 777a∨成人精品桃花网| 中文成人综合网| 天天亚洲美女在线视频| 懂色av中文字幕一区二区三区| 日本丶国产丶欧美色综合| 精品欧美一区二区三区精品久久 | 久久狠狠亚洲综合| 91香蕉国产在线观看软件| 91精品国产色综合久久不卡蜜臀 | 欧美日韩专区在线| 国产午夜精品久久| 五月天激情综合| 成人深夜在线观看| 日韩欧美另类在线| 亚洲美女视频一区| 久久99热国产| 欧美性生活久久| 国产精品入口麻豆九色| 蜜桃av一区二区| 欧美亚洲日本一区| 国产精品国产自产拍在线| 久久精品免费观看| 欧美岛国在线观看| 亚洲欧洲精品一区二区三区| 蜜臂av日日欢夜夜爽一区| 色999日韩国产欧美一区二区| 日韩精品在线一区二区| 亚洲国产视频网站| 91亚洲国产成人精品一区二三| 精品欧美一区二区久久 | 成人美女视频在线观看| 日韩欧美在线影院| 亚洲mv大片欧洲mv大片精品| 色综合久久久久综合体桃花网| 久久婷婷久久一区二区三区| 日韩精品每日更新| 欧美日韩一级黄| 一区二区三区四区不卡在线| 国产aⅴ精品一区二区三区色成熟| 欧美一区二区三区小说| 亚洲成人免费影院| 欧美性高清videossexo| 亚洲欧洲av在线| 成人精品视频一区二区三区 | 亚洲免费大片在线观看| 国产美女一区二区| 精品国产污污免费网站入口| 天堂va蜜桃一区二区三区| 欧美综合在线视频| 亚洲欧美日韩久久精品| 99re热视频这里只精品| 亚洲欧美综合色| 成年人国产精品| 中文字幕一区二区三| 成人久久18免费网站麻豆| 中文字幕国产一区二区| 成人在线一区二区三区| 欧美国产97人人爽人人喊| 高清久久久久久| 国产精品久久久久久久浪潮网站| 久久66热re国产| 久久综合九色综合97婷婷| 国产一区美女在线| 久久久高清一区二区三区| 国产成人午夜视频| 国产欧美一区二区精品秋霞影院 | 91精选在线观看| 午夜欧美电影在线观看| 欧美精品第1页| 免费不卡在线视频| 欧美精品一区二区三区四区| 国产一区二区h| 国产精品素人一区二区| 成人av在线一区二区三区| 亚洲少妇中出一区| 在线亚洲免费视频| 青娱乐精品视频在线| 久久久久久久久久看片| 成人app网站| 夜夜揉揉日日人人青青一国产精品| 欧美伊人精品成人久久综合97| jvid福利写真一区二区三区| 亚洲色图20p| 91精品国产综合久久婷婷香蕉 | 欧美最猛黑人xxxxx猛交| 日韩国产高清影视| 久久综合狠狠综合久久综合88| 国产成人在线观看| 一区二区三区在线视频免费观看| 91精品国产综合久久久蜜臀粉嫩| 国产主播一区二区| 综合电影一区二区三区| 精品视频1区2区| 韩国视频一区二区| 亚洲欧美精品午睡沙发| 91麻豆精品国产91久久久久| 国产成人午夜99999| 亚洲一区日韩精品中文字幕| 日韩女优制服丝袜电影| 99精品视频一区二区| 日韩精品高清不卡| 亚洲欧美综合在线精品| 日韩亚洲欧美一区| www.日韩av|