TIdUDP sockets in XE5 questions

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

TIdUDP sockets in XE5 questions

Postby BReeves » Sat Mar 26, 2016 4:15 am

I am creating two apps that need to talk to each other which will on the same PC, one using BCB5 and one using BCBXE5. Thought I would use the FastNet UDP control as I have used it in BCB5 many times without issues. In BCB5 it's real easy to send and receive simple strings in XE5 not so much. I just spent most of the night on Google trying to figure out exactly how to receive a string with TIdUDPSocket in XE5 and now just as confused as ever.

The OnDataReceived event in the BCB5 version doesn't work the same way in the the XE5 version and they have added a LocalHost property that I have no idea what to set to. The computer will not be connected to a network and won't be able to guarantee it will even be assigned a local IP address.

Guess my questions are.
Anyone have a simple example of detecting when and retrieving a string with the TIdUDPSocket control in XE5?
What settings for ports and hosts would work with both apps running on the same computer?
Is there a better (easier) way to have two apps running on the same computer to communicate with each other?

Thanks
BReeves
Active Poster
Active Poster
 
Posts: 22
Joined: Wed Sep 05, 2012 7:41 am
Location: Catoosa OK

Re: TIdUDP sockets in XE5 questions

Postby rlebeau » Sat Mar 26, 2016 8:41 pm

BReeves wrote:I just spent most of the night on Google trying to figure out exactly how to receive a string with TIdUDPSocket in XE5 and now just as confused as ever.


There is no TIdUDPSocket component. Indy has TIdUDPClient and TIdUDPServer components instead. The deprecated Borland Kylix-era Socket components have a TUDPSocket component. Which are you really using?

BReeves wrote:The OnDataReceived event in the BCB5 version doesn't work the same way in the the XE5 version and they have added a LocalHost property that I have no idea what to set to.


What LocalHost property are you referring to? There is no LocalHost property in any Indy components. Are you maybe using the Kylix-era UDP component instead?

BReeves wrote:The computer will not be connected to a network and won't be able to guarantee it will even be assigned a local IP address.


127.0.0.1 is always available.

BReeves wrote:Anyone have a simple example of detecting when and retrieving a string with the TIdUDPSocket control in XE5?


Not without first establishing exactly which component you are really using. Each component is used differently.

BReeves wrote:What settings for ports and hosts would work with both apps running on the same computer?


Any unused port on 127.0.0.1.

BReeves wrote:Is there a better (easier) way to have two apps running on the same computer to communicate with each other?


There are MANY different ways. Named pipes, mailslots, COM, RPC, sockets, window messages, shared memory. Each has its share of advantages and disadvantages. Use whatever suits your needs.
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1457
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: TIdUDP sockets in XE5 questions

Postby BReeves » Sun Mar 27, 2016 5:20 am

The XE control is TUpdSocket found under the Internet tab, sorry if I misnamed it.

Kinda irrelevant now as I have decided to use Mail Slots to communicate between the two applications. Had forgotten about a project I did several years ago in which I used Mail Slots and was able to port that code over to XE5 which solved the problem.

Sorry for taking up your time to chase my ghost.
BReeves
Active Poster
Active Poster
 
Posts: 22
Joined: Wed Sep 05, 2012 7:41 am
Location: Catoosa OK

Re: TIdUDP sockets in XE5 questions

Postby rlebeau » Mon Mar 28, 2016 4:52 pm

BReeves wrote:The XE control is TUpdSocket found under the Internet tab, sorry if I misnamed it.


The components in the Web.Win.Sockets unit have been deprecated for a long time, and were finally removed in XE6. You really shouldn't be using them at all. Even in earlier versions before they were removed, they were not very good components to use. You should use the Indy components instead, if not another component suite, like ICS or Synapse.
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1457
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA


Return to Technical

Who is online

Users browsing this forum: Bing [Bot] and 6 guests

cron