服务器端程序问题
#include <vcl.h>
#pragma hdrstop
#include "Mainform.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
this->Memo1->Text="";
this->RichEdit1->Text="";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{//监听
this->ServerSocket->Port=StrToInt(this->Edit1->Text);
this->ServerSocket->Active=true;
this->StatusBar1->SimpleText="正在监听客户端连接状态......";
}
//---------------------------------------------------------------------------
bind
void __fastcall TForm1::BitBtn3Click(TObject *Sender)
{//断开
this->ServerSocket->Close();
this->StatusBar1->SimpleText="已经断开与客户端的连接";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn4Click(TObject *Sender)
{//发送
this->ServerSocket->Socket->Connections[0]->SendText(this->RichEdit1->Text);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ServerOnAccept(TObject *Sender,
TCustomWinSocket *Socket)
{
this->RichEdit1->Clear();
this->StatusBar1->SimpleText="连接到:"+this->ServerSocket->Socket->RemoteAddress;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ServerOnClientRead(TObject *Sender,
TCustomWinSocket *Socket)
{
this->Memo1->Lines->Add(Socket->ReceiveText());
}
能看出来上面的代码错在哪吗,为什么和客户端连不上呢