Building a Server Application in Delphi
(Page 1 of 5 )
In this article, the second part of a series, we will continue discussing how TCP/IP works in tandem with client server applications. Then, we are going to use this knowledge to implement the server part of an example client-server application with Delphi. We are also going to look at the various components that are available to create network applications.
A
downloadable zip file is available for this article.
In this article we will continue discussing how TCP/IP works in tandem with client server applications. In the last article we discussed and saw how TCP/IP works and we have also learned how TCP/IP sends messages around a network. We also looked inside a typical TCP/IP message. Typically two computers on a network communicate through a sequence of numbers and acknowledgments as we've seen in the previous article. We'll start this article by showing you the "text" part of that example.
Below is a snippet of the actual text in the packet that was sent:
0010 03 e6 07 f1 40 00 80 06 6d cd c0 a8 00 01 c0 a8 ....@... m.......
0020 00 02 0b 35 04 2f 0a 8f 0c 6b 51 53 f1 a2 50 18 ...5./.. .kQS..P.
0030 fd 1b 9e 6c 00 00 3c 3f 78 6d 6c 20 76 65 72 73 ...l..<? xml vers
0040 69 6f 6e 3d 22 31 2e 30 22 3f 3e 0d 0a 3c 53 4f ion="1.0 "?>..<SO
0050 41 50 2d 45 4e 56 3a 45 6e 76 65 6c 6f 70 65 20 AP-ENV:E nvelope
0060 78 6d 6c 6e 73 3a 53 4f 41 50 2d 45 4e 56 3d 22 xmlns:SO AP-ENV="
0070 68 74 74 70 3a 2f 2f 73 63 68 65 6d 61 73 2e 78 http://s chemas.x
0080 6d 6c 73 6f 61 70 2e 6f 72 67 2f 73 6f 61 70 2f mlsoap.o rg/soap/
0090 65 6e 76 65 6c 6f 70 65 2f 22 20 53 4f 41 50 2d envelope /" SOAP-
00a0 45 4e 56 3a 65 6e 63 6f 64 69 6e 67 53 74 79 6c ENV:enco dingStyl
00b0 65 3d 22 68 74 74 70 3a 2f 2f 73 63 68 65 6d 61 e="http: //schema
00c0 73 2e 78 6d 6c 73 6f 61 70 2e 6f 72 67 2f 73 6f s.xmlsoa p.org/so
00d0 61 70 2f 65 6e 63 6f 64 69 6e 67 2f 22 3e 3c 53 ap/encod ing/"><S
00e0 4f 41 50 2d 45 4e 56 3a 42 6f 64 79 3e 3c 6d 3a OAP-ENV: Body><m:
00f0 58 5f 47 65 74 49 43 53 53 74 61 74 69 73 74 69 X_GetICS Statisti
0100 63 73 52 65 73 70 6f 6e 73 65 20 78 6d 6c 6e 73 csRespon se xmlns
0110 3a 6d 3d 22 75 72 6e 3a 73 63 68 65 6d 61 73 2d :m="urn: schemas-
0120 75 70 6e 70 2d 6f 72 67 3a 73 65 72 76 69 63 65 upnp-org :service
0130 3a 57 41 4e 43 6f 6d 6d 6f 6e 49 6e 74 65 72 66 :WANComm onInterf
0140 61 63 65 43 6f 6e 66 69 67 3a 31 22 3e 3c 54 6f aceConfi g:1"><To
0150 74 61 6c 42 79 74 65 73 53 65 6e 74 20 78 6d 6c talBytes Sent xml
0160 6e 73 3a 64 74 3d 22 75 72 6e 3a 73 63 68 65 6d ns:dt="u rn:schem
0170 61 73 2d 6d 69 63 72 6f 73 6f 66 74 2d 63 6f 6d as-micro soft-com
0180 3a 64 61 74 61 74 79 70 65 73 22 20 64 74 3a 64 :datatyp es" dt:d
0190 74 3d 22 75 69 34 22 3e 34 35 32 30 37 3c 2f 54 t="ui4"> 45207</T
01a0 6f 74 61 6c 42 79 74 65 73 53 65 6e 74 3e 3c 54 otalByte sSent><T
01b0 6f 74 61 6c 42 79 74 65 73 52 65 63 65 69 76 65 otalByte sReceive
01c0 64 20 78 6d 6c 6e 73 3a 64 74 3d 22 75 72 6e 3a d xmlns: dt="urn:
01d0 73 63 68 65 6d 61 73 2d 6d 69 63 72 6f 73 6f 66 schemas- microsof
01e0 74 2d 63 6f 6d 3a 64 61 74 61 74 79 70 65 73 22 t-com:da tatypes"
01f0 20 64 74 3a 64 74 3d 22 75 69 34 22 3e 35 33 31 dt:dt=" ui4">531
0200 30 37 3c 2f 54 6f 74 61 6c 42 79 74 65 73 52 65 07</Tota lBytesRe
0210 63 65 69 76 65 64 3e 3c 54 6f 74 61 6c 50 61 63 ceived>< TotalPac
0220 6b 65 74 73 53 65 6e 74 20 78 6d 6c 6e 73 3a 64 ketsSent xmlns:d
0230 74 3d 22 75 72 6e 3a 73 63 68 65 6d 61 73 2d 6d t="urn:s chemas-m
0240 69 63 72 6f 73 6f 66 74 2d 63 6f 6d 3a 64 61 74 icrosoft -com:dat
0250 61 74 79 70 65 73 22 20 64 74 3a 64 74 3d 22 75 atypes" dt:dt="u
0260 69 34 22 3e 35 34 32 3c 2f 54 6f 74 61 6c 50 61 i4">542< /TotalPa
0270 63 6b 65 74 73 53 65 6e 74 3e 3c 54 6f 74 61 6c cketsSen t><Total
0280 50 61 63 6b 65 74 73 52 65 63 65 69 76 65 64 20 PacketsR eceived
0290 78 6d 6c 6e 73 3a 64 74 3d 22 75 72 6e 3a 73 63 xmlns:dt ="urn:sc
02a0 68 65 6d 61 73 2d 6d 69 63 72 6f 73 6f 66 74 2d hemas-mi crosoft-
02b0 63 6f 6d 3a 64 61 74 61 74 79 70 65 73 22 20 64 com:data types" d
02c0 74 3a 64 74 3d 22 75 69 34 22 3e 34 31 36 3c 2f t:dt="ui 4">416</
02d0 54 6f 74 61 6c 50 61 63 6b 65 74 73 52 65 63 65 TotalPac ketsRece
02e0 69 76 65 64 3e 3c 4c 61 79 65 72 31 44 6f 77 6e ived><La yer1Down
02f0 73 74 72 65 61 6d 4d 61 78 42 69 74 52 61 74 65 streamMa xBitRate
0300 20 78 6d 6c 6e 73 3a 64 74 3d 22 75 72 6e 3a 73 xmlns:d t="urn:s
0310 63 68 65 6d 61 73 2d 6d 69 63 72 6f 73 6f 66 74 chemas-m icrosoft
0320 2d 63 6f 6d 3a 64 61 74 61 74 79 70 65 73 22 20 -com:dat atypes"
0330 64 74 3a 64 74 3d 22 75 69 34 22 3e 32 32 37 32 dt:dt="u i4">2272
0340 30 30 30 3c 2f 4c 61 79 65 72 31 44 6f 77 6e 73 000</Lay er1Downs
0350 74 72 65 61 6d 4d 61 78 42 69 74 52 61 74 65 3e treamMax BitRate>
0360 3c 55 70 74 69 6d 65 20 78 6d 6c 6e 73 3a 64 74 <Uptime xmlns:dt
0370 3d 22 75 72 6e 3a 73 63 68 65 6d 61 73 2d 6d 69 ="urn:sc hemas-mi
0380 63 72 6f 73 6f 66 74 2d 63 6f 6d 3a 64 61 74 61 crosoft- com:data
0390 74 79 70 65 73 22 20 64 74 3a 64 74 3d 22 75 69 types" d t:dt="ui
03a0 34 22 3e 31 36 39 3c 2f 55 70 74 69 6d 65 3e 3c 4">169</ Uptime><
03b0 2f 6d 3a 58 5f 47 65 74 49 43 53 53 74 61 74 69 /m:X_Get ICSStati
03c0 73 74 69 63 73 52 65 73 70 6f 6e 73 65 3e 3c 2f sticsRes ponse></
03d0 53 4f 41 50 2d 45 4e 56 3a 42 6f 64 79 3e 3c 2f SOAP-ENV :Body></
03e0 53 4f 41 50 2d 45 4e 56 3a 45 6e 76 65 6c 6f 70 SOAP-ENV :Envelop
03f0 65 3e 0d 0a e>..
This is a typical view of a packet sent between two computers on a network. The data packet is sent in XML format wrapped in a SOAP envelope.
If data gets lost between the sending and receiving computers, TCP retransmits the packet until it reaches its destination or until a timeout limit is reached. Other features of TCP/IP let it recognize duplicate messages and get rid of them appropriately; it also detects whether a sending computer is transmitting too fast for the receiving computer. If it is, TCP/IP engages its flow control methods to slow down data transfer.
Next: Application Support >>
More Delphi-Kylix Articles
More By Leidago