3

First of all my intend is to create 2 programs server and client to send big byte array. I just started to test with UDPclient and udpserver components. I am not if it is right way.

I found program example but it was built with an old Delphi version, when I compile I am getting an error.

HostName.Caption := UDPServer.LocalName;
HostAddress.Caption := GStack.LocalAddress;
Port.Caption := IntToStr(UDPServer.DefaultPort);
BufferSize.Caption := IntToStr(UDPServer.BufferSize);
UDPServer.Active := True;

it seems udpserver.localname was in old versions. I need to find what property to use in here . How to get and write Host name in udpserver components. udpclient has Host property and workes fine, I could compile client program

Can anyone help me what to put instead of "localname" property

And if anyone can advice me another way to send big byte arrays. the size of it will be about 120000 . I will send it in every minute

Thank you

Warren P
  • 65,725
  • 40
  • 181
  • 316
Samir Memmedov
  • 149
  • 1
  • 2
  • 11
  • Why are you using UDP instead of TCP? – FHannes Jun 03 '12 at 15:51
  • I dont know, I dont have specific reason, just started with UDP – Samir Memmedov Jun 03 '12 at 16:17
  • 4
    Well first learn the difference between UDP and TCP. In UDP you don't have the warranty that you will receive a sent packet and the order of the received packets could be different than the sent order. UDP is typically used in realtime protocols (like VOIP, games, ...). If this is not a prerequisite I strongly suggest you take the TCP route as it is a lot easier to learn... – whosrdaddy Jun 03 '12 at 16:46
  • It is not real time, it will send data frquently once a minute, and there will be about 10 clients. Ok thank you for your advice. I will look at TCP. Thanks guys for replies – Samir Memmedov Jun 03 '12 at 16:55

3 Answers3

4

It's best to use TCP as it can detect data-corruption in your transmission and request the corrupted packets again. The detection happens by checking packets against a 16-bit checksum, this will only detect errors, but not allow the system to correct it, which is where requesting the data again comes in.

It's probably most convenient to use the Indy socket library that comes with Delphi to create TCP sockets. The TIdTCPServer and TIdTCPClient components should do the job nicely.

You can find some demo's on using the Indy library here:

FHannes
  • 783
  • 7
  • 22
  • Your second sentence could be referring to either UDP or TCP or both. It is most unclear. In any case neither TCP nor UDP uses parity bits, they use a 16-bit checksum. – user207421 Jun 04 '12 at 04:59
  • @EJP You're right, my bad, it's been quite a while since I got my introduction course to network protocols at college. – FHannes Jun 04 '12 at 07:00
1

GStack.HostName is the replacement for the old LocalName property.

UDP is a message-based transport. 120000 is too many bytes to fit in a single UDP message. You will have to break it up into small chunks. To send large amounts of data using UDP, consider using a UDP-based transfer protocol, such as TFTP. Indy has TIdTrivialFTP and TIdTrivialFTP components for that purpose.

Otherwise, switch to TCP, which is a stream-based transport. Then you can send as much data as you want.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
0

It depends on the data you are trying to send over network. If you want to send a file over network, you should use TCP protocol because it guarantees that the data received at server-side will be the same sent on the client-side. If the data you want to send is lossy like Voice (I mean it's not important we have delays or losses in the middle and in data) you can use UDP protocol. It'll be very faster because it has no overhead for checking the data against corruption. In UDP you may loose your packets or datagrams so UDP is called a connection-less protocol because there is no connection in fact. I think all known programming languages support TCP and UDP connections.

Kamran Amini
  • 1,062
  • 8
  • 14