1

I want to create a software to connect to another and send some data (text based) to another program through the internet.

The software will send data every 300 milliseconds (using timer) and the receiver must receive the data on time.

The connection can be like the following

  1. any data can be lost;
  2. but the rest must arrive on time with minimum delay as possible (maximum 2 seconds);
  3. the delayed data can be considers as lost, can be ignored.

I think it may be similar to a video conference software, but only using simple text as data.

Can anyone tell me how to make such a program, specifically

  • what kind of component can I use (any INDY examples);
  • what technologies do you recommend.

I have planned to do it with Delphi but other recommendation also welcome .

==========================update1 =================

Is it possible to send images through the stream

Vibeeshan Mahadeva
  • 7,147
  • 8
  • 52
  • 102

2 Answers2

3

I suggest using UDP protocol and adding timestamp information to your data and track incoming data on the receiving end. You can use UDP server (TIdUDPServer) and client (TIdUDPClient) components from Indy or other packages. Client component is for sending data and server for receiving.

Personally I usually prefer Synapse -classes. They are lower level than Indy, so it's easier to know what's happening but on the otherhand you may need to implement something yourself what Indy may provide by default.

Update

Implementation is pretty straight forward:

Sending data:

Drop TIdUDPClient on the form. Set "Host" to name or IP address of receiving end (or "localhost" if you run your programs in same computer) and port to high number where server is listening, eg 54656.

Add following code to button or timer event:

IdUDPClient1.Send('Hello, world!');

Receiving data:

Drop TIdUDPServer component on the form. Set default port to same port as in sending application. Add OnUDPRead event handler, with code:

MessageDlg('Received: ' + StringOf(AData), mtInformation, [mbOk], 0);

And new message dialog pops up everytime new message is received.

Update 2

UDP is not good for images, if you want to be sure they will stay uncorrupted, unless the image is very small and fits inside one packet.

Harriv
  • 6,029
  • 6
  • 44
  • 76
  • 1
    For up to 100 clients or so, TCP is easier. UDP scales much better for a larger number of clients and also works well for discrete (short) messages that you can afford to lose. – Misha Oct 19 '11 at 12:46
  • @Misha I think it depends on what's the goal of application. If you're streaming online data and you're only interested on latest arrived data, in my opinion UDP is easier because you don't have to worry about connecting, disconnecting, delays etc. – Harriv Oct 19 '11 at 14:28
  • @Harriv, yes, as long as each message is self-contained and fits neatly into a packet (as your update above explains). – Misha Oct 20 '11 at 00:28
0

I'd recommend using anything but Indy. It is both buggy (especially versions bundled with Delphi) and slower than other component sets. It is easy to understand and start using it, but once you delve deeper under the hood, you start noticing small problems. Indy is constantly under development and you can find latest build here. Problem is that you can't easily replace the bundled version with newer in Delphi versions from 2009 onward because of some hard-coded dependencies.

Delphi has few other network communication methods integrated, but I recommend exploring 3rd party components. First, if you want open source, you should take a look at Overbyte ICS. It is a bit difficult to master, but it has good performance and feature set.

As a very good commercial solution, take a look at IP^Works. I have only scratched it, but from what I saw, I can wholeheartedly recommend it.

LightBulb
  • 964
  • 1
  • 11
  • 27
  • 1
    Rubbish! I have been using Indy in production since 2004. I have over 20 different applications (servers and clients) out there all communicating with Indy and I have never ever had a problem with the Indy components. Yes, if you take the latest build on a daily basis then there might be the odd issue, but these are quickly fixed. You can see how I built an entire generic communication framework from the download on my web site (http://www.csinnovations.com/framework_delphi.htm). – Misha Oct 19 '11 at 12:11
  • I have to correct myself since what I explained is related to protocol specific component issues, like IMAP. The `TIdTCPServer` and `TIdTCPClient` on the other hand are quite good, though I still claim that other component sets outperform Indy, especially in time-critical tasks. – LightBulb Oct 19 '11 at 12:18
  • Fair enough about the specific component sets (I don't really use anything outside of TCP, UDP, HTTP, and SMTP). Given that I can get delays in the order of milliseconds communicating with Indy and throughput of 20-50 Mbps for a connection, I suspect that any performance limitations are more in the implementation than Indy itself. As to how far you can push Indy, have a look at my question here - http://stackoverflow.com/questions/7150093/scalable-delphi-tcp-server-implementation. – Misha Oct 19 '11 at 12:36
  • @LightBulb: the "hard-coded dependancies" on Indy in Embarcadero packages were removed in XE/XE2 to make Indy upgrades easier on users without breaking anything. – Remy Lebeau Oct 19 '11 at 16:05
  • @RemyLebeau-TeamB: I know that, but what about us who are stuck with older versions of Delphi, especially 2009/10? You can't expect us to upgrade Delphi just to be able to use a crucial component set. My point is that I need component set that works and it does exactly what is expected from it. That's why I'd still recommend against Indy if you need time-critical and long-lasting functionality. – LightBulb Oct 20 '11 at 04:57
  • You can still upgrade Indy in those versions. If you need to use DataSnap or any other product that has a dependency on the IDE-shipped version of Indy, you can maintain that version side-by-side, and switch between the two versions on a per-project basis. – Remy Lebeau Oct 20 '11 at 15:19