Question : The choice of Transport : TCP or UDP

I am trying to write a real-time gateway application based on TCP/IP peer to peer architecture. The application is to transfer data from a realtime database in Linux and a database in Windows.
The linux side of the gateway will act more like a server, it will send all the changes to windows side of the gateway, data changes willl be packeted to send out every predefined interval for efficiency purpose.
Changes can be made on windows side and send back to linux because of user intervention. It happens occasionaly
It is important the data be able to mirror to Windows side as quickly as possible.
The gateway should be able to handle  network disconnection and re-establish the connection automatically.  There should be no loss in data.
My question is to find out which transport TCP or UDP is more sutiable for the job?  Is there some good application in public domain I can  used as a based for my development. Please provide some explanation too.  Thanks.

Answer : The choice of Transport : TCP or UDP

UDP is used specially when you need 1)async operation 2) use broadcast so it can be received by multiple clients or servers, the delivery is not guaranteed (packets can be lost) and you have to make additional code to insure correct receive and  send, in database related applications it is better to use TCP because you can create one session or more between clients and the server and deal correctly with data transports between them.
when you said predefined intervals that mean it is not real-time (in database context)
in your case you need also  to implement something like two phase commit so you can insure that the windows database server is updated correctly and if not rollback transaction of the Unix machine

Final words it is better to use  TCP, but also if the windows database is sqlserver you can use linked servers and make a windows program or service to look for updates and reflected back on the windows database and vise-versa

for more resources and public codes you can search www.codeproject.com for TCP and you will find a lot of articles and sample codes
good luck
Random Solutions  
 
programming4us programming4us