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

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

?? twschat1.cpp

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

Author:       Fran鏾is PIETTE
Description:  TWSChat shows how to use TWSocket to build a chat program
Creation:     November 26, 1997
Version:      1.03
EMail:        francois.piette@swing.be   http://www.rtfm.be/fpiette/indexuk.htm
              francois.piette@rtfm.be    francois.piette@pophost.eunet.be
Support:      Use the mailing list twsocket@rtfm.be See website for details.
Legal issues: Copyright (C) 1997-2000 by Fran鏾is PIETTE
              <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.

Updates:
Jan 10, 1998  V1.02 Corrected CliWSocketDataAvailable
Apr 12, 1998  V1.03 Adapted for BCB3

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

#define ChatPort "2200"
#define TWSChatVersion 102

#include "twschat1.h"
//---------------------------------------------------------------------------
#pragma link "WSocket"
#pragma resource "*.dfm"
TTWSChatForm *TWSChatForm;
//---------------------------------------------------------------------------
__fastcall TTWSChatForm::TTWSChatForm(TComponent* Owner)
    : TForm(Owner)
{
}

//---------------------------------------------------------------------------
void __fastcall TTWSChatForm::StartServer()
{
    // Try to be a server
    SrvWSocket->Port  = ChatPort;
    SrvWSocket->Proto = "tcp";
    SrvWSocket->Addr  = "0.0.0.0";
    try {
        SrvWSocket->Listen();
        RunningRadioButton->Checked = TRUE;
        StoppedRadioButton->Checked = FALSE;
    } catch (const ESocketException &E) {
            // The socket is probably already in use
            RunningRadioButton->Checked = FALSE;
            StoppedRadioButton->Checked = TRUE;
            if (strncmp(E.Message.c_str(), "Error 10048", 11) == 0)
                DisplayMemo->Lines->Add("TWSChat already running as server");
            else
                throw;
    }
}
//---------------------------------------------------------------------------
void __fastcall TTWSChatForm::FormShow(TObject *Sender)
{
    if (!Initialized) {
        Initialized = TRUE;
        StartServer();
    }
}
//---------------------------------------------------------------------------
// The user has clicked on the 'connect' Button-> We will not connect here,
// but start the DNSLookup. We will receive a event when it is complete.
// The connection will be made at that later time.
void __fastcall TTWSChatForm::ConnectButtonClick(TObject *Sender)
{
    ConnectButton->Enabled    = FALSE;
    DisconnectButton->Enabled = TRUE;
    CliWSocket->DnsLookup(ServerEdit->Text);
}
//---------------------------------------------------------------------------
// This event handler is triggered when the DNS lookup process is finished
// successfully or not. If DNS lookud failed, display a message.
// If DNS lookup successfull, ask TWSocket to connect the server.
void __fastcall TTWSChatForm::CliWSocketDnsLookupDone(TObject *Sender,
    WORD Error)
{
    if (Error != 0) {
        // DNS Lookup has failed
        DisplayMemo->Lines->Add("Server name unknown");
        ConnectButton->Enabled    = TRUE;
        DisconnectButton->Enabled = FALSE;
        return;
    }

    // DNS lookup successfull. Try to see if we are the server and we are
    // trying to connect to ourself. Check loopback address, should also
    // check the local IP address (returned by LocalIPList)...
    if ((SrvWSocket->State == wsListening) &&
        (CliWSocket->DnsResult == "127.0.0.1")) {
        DisplayMemo->Lines->Add("Your are trying to connect to yourself !");
        ConnectButton->Enabled    = TRUE;
        DisconnectButton->Enabled = FALSE;
        return;
    }

    // Transfert the IP address from DNSLookup to the TWSocket for connection
    // We could use the hostname for the Addr property, TWSocket will do the
    // DNS lookup for us, but it will block, maybe for a long time if DNS if
    // down.
    CliWSocket->Addr  = CliWSocket->DnsResult;
    CliWSocket->Port  = ChatPort;
    CliWSocket->Proto = "tcp";

    // The connect method is asynchronous. You get the control back quickly
    // The OnSessionConnected event will be eventually generated when the
    // connection is established.
    CliWSocket->Connect();
}
//---------------------------------------------------------------------------
// This event handler is triggered when the connection is established with
// the server. Enable the send button and the message edit box.
void __fastcall TTWSChatForm::CliWSocketSessionConnected(TObject *Sender,
    WORD Error)
{
    if (Error == WSAECONNREFUSED)
        DisplayMemo->Lines->Add("No server available");
    else if (Error != 0)
        DisplayMemo->Lines->Add("Can't connect, error #" + IntToStr(Error));
    else {
        DisplayMemo->Lines->Add("Connected");
        SendButton->Enabled  = TRUE;
        MessageEdit->Enabled = TRUE;
    }
}
//---------------------------------------------------------------------------
// This event is triggered when the client connection is closed, either
// by the client himself or by the local user pushing the disconnect button
void __fastcall TTWSChatForm::CliWSocketSessionClosed(TObject *Sender,
    WORD Error)
{
    DisconnectButton->Enabled = FALSE;
    ConnectButton->Enabled    = TRUE;
    if (SendButton->Enabled) {
        SendButton->Enabled   = FALSE;
        MessageEdit->Enabled  = FALSE;
        DisplayMemo->Lines->Add("Disconnected");
    }
}
//---------------------------------------------------------------------------
// This event is triggered when data has been received from the client.
// A little bit of work here because the data can comes fragmented or in big
// chunks with several client lines. So we assemble the data received in a
// buffer and check the buffer for complete lines (there can be no complete
// line, exactly one complete line, several complete lines and may be an
// incomplete line at the end.
void __fastcall TTWSChatForm::CliWSocketDataAvailable(TObject *Sender,
    WORD Error)
{
    int  Len;
    int  I;

    // Receive the data that has arrived, put it after the data already here
    Len = CliWSocket->Receive(&RcvBuf[RcvLen], sizeof(RcvBuf) - RcvLen - 1);
    if (Len <= 0)
        return;
    // Update our counter
    RcvLen = RcvLen + Len;
    // Place a null byte at the end of the buffer
    RcvBuf[RcvLen] = 0;

    // Scan the buffer to process each complete line
    while (TRUE) {
        // find the terminating line feed
        I = strchr(RcvBuf, 10) - RcvBuf;
        if (I < 0)
            break; // not found, incomplete line, break loop
        // Replace the line feed by a nul char, truncating the line
        RcvBuf[I] = 0;
        // Display the truncated line
        DisplayMemo->Lines->Add("Remote> " + StrPas(RcvBuf));
        // Restore the line feed }
        RcvBuf[I] = 10;
        // Was it the last line in the buffer ?
        if (I >= (RcvLen - 1)) {
            RcvLen = 0;
            break;
        }
        // Not the last line, move the next one in front of buffer
        memmove(RcvBuf, &RcvBuf[I + 1], RcvLen - I);
        RcvLen = RcvLen - I;
    }
}
//---------------------------------------------------------------------------
// This event is triggered when we - as a server - have received a client
// connection request. We must accept the connection. Two cases: we are
// already busy with another client, or this is the first client connecting.
void __fastcall TTWSChatForm::SrvWSocketSessionAvailable(TObject *Sender,
    WORD Error)
{
    if (CliWSocket->State == wsConnected) {
        // We are already busy with a client. Use the TmpWSocket to send a
        // busy message to the second client. Display a message to notify
        // the user that someone is trying to contact him.
        TmpWSocket->HSocket = SrvWSocket->Accept();
        DisplayMemo->Lines->Add("System> " + TmpWSocket->GetPeerAddr() +
                              " is trying to call you");
        TmpWSocket->SendStr("Busy ! Try later...\r\n" );
        TmpWSocket->Close();
        return;
    }

    // This is our first client trying to connect, we accept
    CliWSocket->HSocket       = SrvWSocket->Accept();
    ConnectButton->Enabled    = FALSE;
    DisconnectButton->Enabled = TRUE;
    SendButton->Enabled       = TRUE;
    MessageEdit->Enabled      = TRUE;
    DisplayMemo->Lines->Add("Connected with " + CliWSocket->GetPeerAddr());
}
//---------------------------------------------------------------------------
// The user clicked on the disconnect Button->
void __fastcall TTWSChatForm::DisconnectButtonClick(TObject *Sender)
{
    CliWSocket->Close();
}
//---------------------------------------------------------------------------
// The user has clicked on the send Button-> Just send the data in the edit
// box and a CRLF pair to make a complete line.
void __fastcall TTWSChatForm::SendButtonClick(TObject *Sender)
{
    CliWSocket->SendStr(MessageEdit->Text + "\r\n");
    DisplayMemo->Lines->Add(" Local> " + MessageEdit->Text);
}
//---------------------------------------------------------------------------
void __fastcall TTWSChatForm::StoppedRadioButtonClick(TObject *Sender)
{
    SrvWSocket->Close();
    RunningRadioButton->Checked = FALSE;
    StoppedRadioButton->Checked = TRUE;
}
//---------------------------------------------------------------------------
void __fastcall TTWSChatForm::RunningRadioButtonClick(TObject *Sender)
{
    if (SrvWSocket->State != wsListening)
        StartServer();
}
//---------------------------------------------------------------------------

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕欧美三区| 欧美一级午夜免费电影| 国产精品黄色在线观看| 国产91精品欧美| 自拍偷拍欧美激情| 欧美亚洲一区二区三区四区| 亚洲综合免费观看高清完整版在线| 欧洲在线/亚洲| 日韩精品电影在线观看| 久久综合九色综合97婷婷| 国产一级精品在线| 中文字幕亚洲区| 欧美性猛交xxxx乱大交退制版| 午夜精品一区二区三区电影天堂| 欧美大肚乱孕交hd孕妇| 懂色av一区二区三区蜜臀| 中文字幕人成不卡一区| 欧美人伦禁忌dvd放荡欲情| 国产在线国偷精品免费看| 综合久久国产九一剧情麻豆| 欧美老年两性高潮| 国产在线日韩欧美| 亚洲美女区一区| 日韩欧美综合一区| 波多野结衣精品在线| 亚洲成在人线在线播放| 精品嫩草影院久久| 在线欧美小视频| 国产盗摄一区二区| 亚洲va国产天堂va久久en| 国产精品欧美一区喷水| 欧美欧美午夜aⅴ在线观看| 高清shemale亚洲人妖| 亚洲不卡av一区二区三区| 国产精品三级电影| 91精品综合久久久久久| 99这里只有久久精品视频| 久久精品理论片| 亚洲国产精品久久人人爱蜜臀 | a美女胸又www黄视频久久| 日韩中文字幕区一区有砖一区 | 丝袜诱惑亚洲看片| 自拍偷拍国产精品| 久久久不卡网国产精品一区| 欧美理论在线播放| 91福利在线免费观看| 成人美女在线视频| 久久99久久精品| 午夜亚洲国产au精品一区二区 | 亚洲午夜三级在线| 欧美国产日韩a欧美在线观看| 欧美精品一级二级| 91欧美激情一区二区三区成人| 国内一区二区视频| 免费亚洲电影在线| 亚洲一二三四在线观看| 亚洲婷婷综合久久一本伊一区| 精品欧美乱码久久久久久1区2区| 欧美三级蜜桃2在线观看| 91网站黄www| 成人教育av在线| 国产一区视频导航| 国产又粗又猛又爽又黄91精品| 美女一区二区视频| 亚洲成人av电影| 亚洲图片有声小说| 一区二区三区四区乱视频| 亚洲欧美日韩一区| 亚洲欧美偷拍卡通变态| 综合久久久久久| 亚洲日本韩国一区| 亚洲欧美激情视频在线观看一区二区三区| 国产亚洲精品中文字幕| 久久久久综合网| 欧美极品aⅴ影院| 中文字幕精品三区| 亚洲国产电影在线观看| 中文字幕中文乱码欧美一区二区| 亚洲国产高清在线观看视频| 中文字幕av在线一区二区三区| 久久久精品黄色| 国产精品污污网站在线观看 | 亚洲精品乱码久久久久久日本蜜臀| 国产欧美日韩在线看| 国产欧美精品区一区二区三区 | 亚洲人成网站色在线观看| 亚洲欧美福利一区二区| 亚洲图片欧美综合| 视频一区国产视频| 久久99精品网久久| 国产中文字幕一区| jvid福利写真一区二区三区| 99久久国产综合色|国产精品| 99re在线精品| 欧美日韩午夜精品| 精品国产一区二区三区不卡| 国产日韩欧美一区二区三区综合 | 在线一区二区视频| 欧美一级日韩不卡播放免费| 26uuu成人网一区二区三区| 国产欧美日韩在线观看| 亚洲精品日韩专区silk| 婷婷国产v国产偷v亚洲高清| 久久99国产精品久久99果冻传媒| 国产成人综合网| 日本精品一级二级| 欧美成人国产一区二区| 国产精品久久久久久久久图文区| 一区二区不卡在线播放| 麻豆久久一区二区| av一区二区三区在线| 欧美日韩黄视频| www国产亚洲精品久久麻豆| 亚洲欧美激情在线| 久久99精品久久久久久久久久久久| 国产成人精品免费一区二区| 欧美色精品天天在线观看视频| 日韩美女在线视频| 亚洲精品免费视频| 国产精品亚洲第一区在线暖暖韩国| 99久久精品情趣| 日韩欧美中文字幕一区| 亚洲视频一二区| 激情综合色播五月| 欧美影片第一页| 国产日本欧美一区二区| 亚洲福利视频一区| av电影在线观看一区| 日韩精品一区国产麻豆| 亚洲品质自拍视频| 国产成a人亚洲精| 91精品国产乱码| 一区二区在线观看免费视频播放| 国内精品在线播放| 4hu四虎永久在线影院成人| 中文字幕在线观看不卡| 久久国产日韩欧美精品| 欧美日韩一区二区三区免费看| 国产午夜亚洲精品午夜鲁丝片| 亚洲成av人片在线| 色8久久精品久久久久久蜜| 国产女同性恋一区二区| 免费成人性网站| 欧美色手机在线观看| 国产精品夫妻自拍| 国产精品一区二区久久精品爱涩| 欧美一区二区观看视频| 亚洲香肠在线观看| 色婷婷精品久久二区二区蜜臀av| 国产三级精品三级| 国产毛片一区二区| 日韩精品一区二区三区中文精品| 日韩电影在线免费| 欧美在线视频你懂得| 亚洲天堂av一区| av一本久道久久综合久久鬼色| 国产亚洲欧美一级| 国产成人免费在线观看| 26uuu成人网一区二区三区| 久久99蜜桃精品| 欧美大度的电影原声| 麻豆一区二区99久久久久| 欧美一级专区免费大片| 日本不卡中文字幕| 日韩一级片在线观看| 奇米一区二区三区| 欧美一区二区三区在线视频| 日本在线不卡一区| 91精品国产黑色紧身裤美女| 日本女人一区二区三区| 欧美mv日韩mv国产网站app| 老司机精品视频导航| 精品欧美一区二区三区精品久久| 久久精品国产亚洲一区二区三区| 欧美一区二区黄| 国产做a爰片久久毛片| 中文字幕免费不卡| 色综合久久中文综合久久97| 一区二区三区国产精品| 欧美精品一二三四| 极品美女销魂一区二区三区免费| 2020日本不卡一区二区视频| 国产传媒一区在线| 中文字幕一区二区三区四区| 欧美自拍偷拍一区| 日本va欧美va瓶| 国产日韩欧美一区二区三区乱码 | 国产成人亚洲综合a∨婷婷 | 九色综合国产一区二区三区| 国产视频视频一区| 一本到不卡免费一区二区| 亚洲成人中文在线| 久久综合资源网| 成a人片亚洲日本久久| 亚洲一区二区三区四区不卡| 日韩欧美国产综合| proumb性欧美在线观看| 日韩av一级片| 国产精品视频一二三| 欧美精品tushy高清|