ماهي طريقة ارسال الى اكثر من عميل
#1
السلآم عليكم ورحمة الله وبركاته....

اخوتي الاعزاء ...

ماهي طريقة الارسال الى اكثر من عميل حيث اني وجدت طريقة لكن فيها مشكلة ويقوم بأعطائي الخطأ التالي :

List Index Out Of Bounds (1

الكود الذي استخدمته

كود :
procedure TForm4.redt1Change(Sender: TObject);
   var
   Range: IHTMLTxtRange;
   i:integer;
begin
Range := ((wb1.Document AS IHTMLDocument2).body AS IHTMLBodyElement).createTextRange;
Range.collapse(false);
Range.PasteHTML(format('<p>%S<p/>',[redt1.Text]));
FlashWindow(Application.Handle, True);
if (form1.Sv1.Socket.ActiveConnections > 0) then
wb1.OleObject.Document.ParentWindow.ScrollBy(0, +1000000000);
FlashWindow(Application.Handle, True);
begin
for i := 0 to form1.Sv1.Socket.ActiveConnections-1 do
begin
Form1.sv1.Socket.Connections[0].SendText(redt1.text);
Form1.sv1.Socket.Connections[1].SendText(redt1.text);
Form1.sv1.Socket.Connections[2].SendText(redt1.text);
Form1.sv1.Socket.Connections[3].SendText(redt1.text);
Form1.sv1.Socket.Connections[4].SendText(redt1.text);
Form1.sv1.Socket.Connections[5].SendText(redt1.text);
Form1.sv1.Socket.Connections[6].SendText(redt1.text);
Form1.sv1.Socket.Connections[7].SendText(redt1.text);
wb1.OleObject.Document.ParentWindow.ScrollBy(0, +1000000000);
FlashWindow(Application.Handle, True);
redt1.Clear;
end;
end;
end;

شكراً لكم

اللهمّ إنّي ظلمت نفسي ظلماً كثيراً ولا يغفر الذّنوب إلا أنت

فاغفر لي مغفرة من عندك وارحمني إنّك أنت الغفور الرّحيم
الرد
#2
اخوتي الاعزاء وجدت الحل :


كود :
var
  i: integer;
begin
     Str:=Edit1.Text;//Take the string (message) sent by the server
     Memo1.Text:=Memo1.Text+'me: '+Str+#13#10
     Edit1.Text:='';//Clears the edit box
//Sends the messages to all clients connected to the server
     for i:=0 to ServerSocket1.Socket.ActiveConnections-1 do
      ServerSocket1.Socket.Connections[i].SendText(str);//Sent
end;


يجب كتابة الكود على الشكل التالي فقط :d

شكراً للجميع

اللهمّ إنّي ظلمت نفسي ظلماً كثيراً ولا يغفر الذّنوب إلا أنت

فاغفر لي مغفرة من عندك وارحمني إنّك أنت الغفور الرّحيم
الرد


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم