R
royalo
Unregistered / Unconfirmed
GUEST, unregistred user!
我放置一个ServerSocket在FORM1,我在FORM2中调用ServerSocket发送信息时,为什么提示raised exception class Esocketerror with message 'Windows socket error:'由于套接字没有连接并且(当使用一个sendto调用发送数据报套接字时)没有提供地址,发送或接收数据的请求没有被接受。(10057),on API 'send' 错误呢?(新人,分没多少,请包涵,谢谢)
//以下代码点击按钮是提示以上错误
procedure TForm2.Button1Click(Sender: TObject);
begin
form1.ServerSocket1.Socket.SendText(memo1.Text);
end;
//以下代码在Clientsocket发送其他消息被Serversocket接受后,
//就会提示另一个错误如下:
//raised exception class EPrivilege with message 'Privileged instruction'
procedure TForm1.ServerSocket1ClientRead(Sender: TObject; Socket: TCustomWinSocket);
var
s:string;
begin
s:=socket.ReceiveText;
//传送信息
if pos('chat',s)>0 then
begin
form2.Memo2.Clear;
form2.Memo2.Text:=s ;
form2.Memo2.Lines.Delete(0);
chat_reply:=strtointdef(form2.Memo2.Lines.Strings[0],0);
form2.Memo2.Lines.Delete(0);
if chat_reply = 1 then
begin
form2.Memo2.ReadOnly:=false;
form2.Button1.Visible:=true;
form2.ShowModal;
socket.SendText('info'+#13+#10+form2.Memo2.Text);
end else
begin
form2.Memo2.ReadOnly:=true;
form2.Button1.Visible:=false;
form2.ShowModal;
end;
end;
end;
//以下代码点击按钮是提示以上错误
procedure TForm2.Button1Click(Sender: TObject);
begin
form1.ServerSocket1.Socket.SendText(memo1.Text);
end;
//以下代码在Clientsocket发送其他消息被Serversocket接受后,
//就会提示另一个错误如下:
//raised exception class EPrivilege with message 'Privileged instruction'
procedure TForm1.ServerSocket1ClientRead(Sender: TObject; Socket: TCustomWinSocket);
var
s:string;
begin
s:=socket.ReceiveText;
//传送信息
if pos('chat',s)>0 then
begin
form2.Memo2.Clear;
form2.Memo2.Text:=s ;
form2.Memo2.Lines.Delete(0);
chat_reply:=strtointdef(form2.Memo2.Lines.Strings[0],0);
form2.Memo2.Lines.Delete(0);
if chat_reply = 1 then
begin
form2.Memo2.ReadOnly:=false;
form2.Button1.Visible:=true;
form2.ShowModal;
socket.SendText('info'+#13+#10+form2.Memo2.Text);
end else
begin
form2.Memo2.ReadOnly:=true;
form2.Button1.Visible:=false;
form2.ShowModal;
end;
end;
end;