Send txt to Many Computer With "NMMsg1"

Hello and happy new year ( 2000 )!!!

i'am using "NMMsg1" internet component in Delphi
i have computers on LAN, i have build client/server application that is listening. I want from my computer to send a message to many computers on the LAN with this component, do i have to make "for loop" or what exception if computer not answer.

that would be great if i can let the "NMMsg1" component read from listbox or something. Thanks

karen021897Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hubdogCommented:
I think may be you can use TNMUDP to broadcast msg .You can set the nmudp.remotehost:=255.255.255.255 to broadcast over intranet to all computers.
0
karen021897Author Commented:
No i will be able to use "NMMsg1" component because i'm going to do lots more with my program e.g read and write to registry and much more, this is just one part ( send message to listener ( computer on LAN )

Client sends and Server Receive with variable "sMsg" and the code is like that "ShowMessage(sMsg);"

i just want to be able to send to many computer

Thanks
Karen
0
almillerCommented:
The NMMsg component, in combination with it's server, is a nice way to accomplish what you are trying to do. The NMMsg can only send a message to one server at a time, so I guess the answer is yes, you would have to make a for-loop.

The server returns an OK message if the message was received, so check the result of PostIt to make sure the message got throuhg ok, and if not, take the necessary steps.

I had a simiilar need once, but since I dont need much more than sending a message, I decided to use NetBEUI's broadcast capabilities (WinPopup), and so on NT I wouldn't even need a client app, cause it has a built in Messenger service. The NetBEUI interface also allows group broadcasts etc.
0
Why Diversity in Tech Matter

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference ithrough the Colors of STEM program.

karen021897Author Commented:
how can i use the messenger service on NT?

can you give me example of for loop for NMMSG, send to one computer and wait send to another and wait ............
0
almillerCommented:
The Messenger service in NT, is similar to the Winpopup application in 9x. It simply opens a dialog showing the text of the message arrived. Like Winpopup, it is possible to replace the Messenger service with a different application, but since it's a service, you would have to shut it down before the other app would be able to get messages.

It should be a simple for loop which changes the host property of the object, and calls PostIt. PostIt will not return until finish, either with an OK result, or something else. If you get something else, take care of it, if not, continue:

For I := 0 to 3 do
begin
  NMMsg1.Host := HostArray[I];
  if NMMsg1.PostIt <> 'OK' then
    {Take care of it}
end;
0
karen021897Author Commented:
can you give me an comple example - please!!!
0
karen021897Author Commented:
You can send mail at karensif@vis.is
0
almillerCommented:
Ok, but I'm kinda'of busy right now. it'll have to be a little later.

....more points will speed things up :)
0
karen021897Author Commented:
alright!!! i raise up to 150 for the answer
0
karen021897Author Commented:
You get more points for working example
0
intheCommented:
hi,
for example look here :
http://www.jgsoftware.com/nt.htm
( very useful site for nt people )

at mez.zip (example of using the nt messiging service via netapi32.dll.
the actual small code that does the work  is in unit2 of the project.


you can also use:
http://home8.inet.tele.dk/tserikse/delphi/mailslot.zip
this is a client/server example for win9* or nt.
a few errors on compiling (integers to cardinal etc..cause it was made in d3 but the demo works well enough when installed.you just need to open the slot ,send the message close the slot ,change client name from \\pc1 to \\pc2 then reopen slot and send message ,close slot ...you know what i mean create a small loop thingy ;-)

sorry if ive just added to the confusion of what comps to use ;-)
Regards Barry
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
karen021897Author Commented:
any example of for loop?
0
karen021897Author Commented:
you may give me loop example please!!!
0
intheCommented:
ok i try and make one but its possible it will be tuesday night gmt  before i get chance to post it(i start work in 6 hrs but only for 2 days then i have proper freetime)
also you will have to test for me to see if it works cause i only have 2 pc's on network (win9*)

oh and which comps you prefer ?

i prefer: mailslot.zip ones (mainly because my nt isnt on network therefore cant test the nt messaging ones)
0
intheCommented:
ok, i thought i tackle this now :-)

i used the mez.zip from jgsoftware link.
i changed the form name to form1
the combobox name to combobox1 and the memo i named memo1 for making it easier to read :untested but should work to sen dsame message to all pcs listed in combobox , this is the button click event:

procedure TForm1.btnSendClick(Sender: TObject);
var
  i, res: Integer;
  pcs_count : integer;
begin
 for pcs_count := 0 to combobox1.Items.Count -1 do begin //start loop
  if Combobox1.Text <> '' then
  begin
    StatusLabel.Font.Color := clBlack;
    StatusLabel.Caption := 'Wait... ';
    Update;
    if Combobox1.Items.IndexOf(Combobox1.Text) = -1 then
      Combobox1.Items.Add(Combobox1.Text);
    res := SendMsg(Combobox1.Text,'',MessageHeader.Text+Memo1.Text);
    if res = 0 then
      Form1.StatusLabel.Font.Color := clBlue
    else
      Form1.StatusLabel.Font.Color := clRed;
    case res of
      0    : Form1.StatusLabel.Caption := 'The message is sent';
      87   : Form1.StatusLabel.Caption := 'The parameter is incorrect';
      123  : Form1.StatusLabel.Caption := 'syntax is incorrect';
      2273 : Form1.StatusLabel.Caption := 'Can not find '+Form1.Combobox1.Text;
    else     Form1.StatusLabel.Caption := 'Error: '+IntToStr(res);
    end;
  end;
  end;  //end loop
end;    //end procedure

can you test it and see if it works
cheers  
 Barry
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.