关于SOCKET的问题
这是参照网上教程写的程序procedure TForm1.Button1Click(Sender: TObject); //打开服务器端的端口
begin
serversocket1.Port:=9999;
serversocket1.Open;
end;
procedure TForm1.Button3Click(Sender: TObject);//客户端连接
begin
clientsocket1.Address:='127.0.0.1';
clientsocket1.Port:=9999;
clientsocket1.Active:=true;
end;
procedure TForm1.ClientSocket1Connect(Sender: TObject; //提示连接成功
Socket: TCustomWinSocket);
begin
showmessage('我连上了');
end;
procedure TForm1.ServerSocket1ClientRead(Sender: TObject; //服务端接受消息
Socket: TCustomWinSocket);
begin
edit1.Text:=serversocket1.Socket.ReceiveText;
end;
procedure TForm1.Button4Click(Sender: TObject); //客户端发送消息
begin
clientsocket1.Socket.SendText('asdfa');
end;
问题是客户端发消息的时候就会出错了,这是为什么呢?