分享

生活化居家实验下的动量和动量定理

 新用户5228KeDY 2022-05-11 发布于北京

别看,凑字数的。

How it works…

This is a long recipe but the behavior is really simple. The

ConfigDispatcher use the two memos to maintain the "strings" to send to theclient that requests a specific configuration. When a client requests a

configuration, the server receives a command string similar to the following:

GETCONFIG#APP001

It parses the command and replies to the client with the contents of one of the

memos. For APP001, it sends the MemoConfigApp1 content while for APP002,it sends the MemoConfigApp2 contents. That's it, the ConfigDispatcher job isfinished.

The client is simple too. On initiation it waits 3 seconds, configured in the

timer, and asks for a configuration. If some data arrives on the UDPServer, theUDPRead event handler is called. The code disables the timer, reads the datasent by the ConfigDiaspatcher, and tries to use it to configure its databaseconnection. If the configuration is correct, the ClientDBApplication

connects to its database; if not, the timer is re-enabled and after 3 seconds,

another configuration request is broadcast and the cycle goes on until the clientis able to connect.

As you can see, the applications talk each other without any kind of predefined

knowledge or configuration. This is the power of UDP!

There's more…

Network programming and network protocols are a really large topic. As a

software developer, you have to be aware - if not yet - of the possibilities thatthe standard networking infrastructure offers you.

The UDP protocol allows you to create strange applications that find and talk

to each other using broadcasts. You could even create a complex applicationprotocol based on UDP to remotely control some running applications. In thechapter devoted to mobile programming, there is another example of the powerof UDP. Here are some other Delphi samples about UDP programming:

Chat application with Delphi source:

http://delphi./library/weekly/aa101105a.htm

A fun utility to invoke fake and harmless BSODs on colleagues' machines:

http://www./indy/demos/10/index.en.aspx

    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多