UDP connection

I have an application that needs to recieve UDP Calls.  On the visual control in delphi I set the remote and local host properties to "LocalHost" and the local port to 44966 and the remote port to 44967.

Then using a sample application from http://www.torry.net/vcl/internet/sockets/tcp_udp.zip I try to send some text to my application with no success. I simply get no response on either of the applications trying to communicate

Any help?
WillemvanzylAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Geert GOracle dbaCommented:
you need 2 different computers as the port is blocked when reading or writing
it's a 1 way communication port

this is the sending of the UDP message

var
  Recipient,SendText: string;

Recipient := 'otherpc@44967';
SendText := 'Message';

Udp := TIdUDPClient.Create(Nil);
try
  with Udp do
  begin
    Host := Copy(Recipient, 0, Pos('@', Recipient) -1);
    Port := StrToInt(Copy(Recipient, Length(Host) + 2, Length(Recipient)));
    Send(SendText);
  end;
finally
  FreeAndNil(Udp);
end;

this is the receving part:
place IdUdpServer on form
UDP_RECEIVER = TIdUdpServer
UDP_RECEIVER.Port := 44967;

procedure TForm1.UDP_RECEIVERRead(Sender: TObject; AData: TStream; ABinding: TIdSocketHandle);
var
  S: TStringStream;
  Msg: String;
begin
  Msg := '';
  if AData.Size > 0 then
  begin
    s := TStringStream.Create('');
    try
      S.CopyFrom(AData, AData.Size);
      Msg := Trim(S.DataString);
    finally
      FreeAndNil(S);
    end;
  end;
  if Msg <> '' then
    ShowMessage(Msg);
end;
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
WillemvanzylAuthor Commented:
...some more background

The Sender is a windows Service that can either be on a server or on the local PC itself. The process works as follows:

Service (Sender) intercepts a print job, and with UDP, notifies a Popup app (reciever), the popup app displays a form that the user has to complete, and then sends a UDP message back to the service to either continue the print job or cancel it.

Wil try out your sample code, thanx
0
JohnjcesCommented:
I am not certain why you are using two different ports for your UDP transmission.

As Geert points out in his sample, the listening and transmitting ports must be the same port.

If you have a UDP Client Socket and UDP Server Socket, they have to be using the same port. Sounds like you are using different ports for different tasks. Make certain that each task uses its correct UDP port.

I have never had a problem using a Client and Server UDP socket on my local host for local testing. UDP is one way, so as an example use port 45678 from client to server and for two way, an additional client and server socket on port 45679 for the reverse communication.

I hope that made some sense.

John
0
Why Diversity in Tech Matters

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 through the Colors of STEM program.

WillemvanzylAuthor Commented:
This is my first UDP development, so me and my co developer are real beginners in regard to UDP. We did start using the same port and then switched to multiple ports. Thanks for the info regarding this. Will implement and revert
0
JohnjcesCommented:
Let us know and don't forget to close the Q.

john
0
WillemvanzylAuthor Commented:
sorted thanx
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
Editors IDEs

From novice to tech pro — start learning today.