Corba chunked response - corba

Is it possible corba service response one request multiple times?
In my case, corba service collects a bunch of data which takes a long time for request. In order to reduce delay client receives response, we want service responses soon when the size of collected data reach 1024k. For example, the total data sizes is 10M, service responses client 10 times on one connection.
My understanding is that corba server should cache connection between client and server, and deliver new data on this cached one once a new data is available. The client, on other handle, should do while loop for incoming response. Either client or server should not close connection until server says all data is connected. This procedure is similar to that in chunked response in Http protocol.
I appreciate if you can provide some tips or sample links in this area.

The CORBA server side is only able to send the data to the client when the server application code returns the function call. If you have just one operation in IDL that returns 10M, than the ORB can only transmit that data to the client when the operation has finished. In order to allow the ORB to send the data it has you have to modify your IDL and add a way for the client to start the operation and than poll for chunks of data to be available. Each implementation of the poll than returns with one chunk.
Some examples of how to do this are part of TAO. You can find the examples under ACE_wrappers/TAO/examples/Content_Server. It also has an example where the server pushes the data to the client when a chunk is available.

Related

queue and flow control with delphi using indy

i have a client server application (TCP) that's designed with indy delphi.
i want to have a queue and flow control in my server side application.
my server should not lose any clients data when server traffic is full.
for example , in my server side application i want determine maximum of bandwidth for server is 10Mbps and then if server bandwidth (this 10Mbps) was full the other clients be on queue until bandwidth get free .
so i want to know how can i design this with delphi ?
thanks
best regard
The client should not send the message directly to the server. Put the message in a local store (f.i. sqlite-db) and in a thread you read the first message from the local store and try to send it to the server.
If the message was delivered to the server (no exception raised) delete the message from the local store and process the next "first" message in the local store.
Within the TIdTCPServer.OnExecute method which receives the client data, it is possible to 'delay' processing of the incoming request with a simple Sleep command. The client data will stay in the TCP socket until the Sleep command finished.
If your server keeps track of the current 'global' bandwidth usage for all clients, it is possible to set the Sleep time dynamically. You could even set different priorities for different clients.
So you would need a simple but thread safe bandwidth usage monitor, an algorithm which calculates sensible Sleep time values, and a way to assign this Sleep time to the individual client connection contexts.
See also:
https://en.wikipedia.org/wiki/Token_bucket
https://github.com/bandwidth-throttle/token-bucket for an example implementation in PHP
http://www.nurkiewicz.com/2011/03/tenfold-increase-in-server-throughput.html

Iphone Client Managing multiple responses at a time using tcp sockets

I am creating an iphone application, the application will use tcp sockets for server side communication, now in my case i will be listening the server using a socket for server side response, and there can be multiple responses in json format at a time which will needed to be displayed in a table view, now i am confused how to cater (parsing response and displaying data) multiple responses at a time, should i use a thread for each incoming response, or use a mutex lock type strategy, so that first response catered first time then the next one, plz. guide, any example with code can be very helpful. thanks in advance.

How to show transfer progress during a DataSnap transmission?

I have a ISAPI DataSnap server and a client application, which communicate over the web. I have been looking for a way to show data transmission progress when the client application is retrieving data or applying updates, but so far I haven't found anything except to set ClientDataSet.PacketRecord to a small number and run a loop to retrieve packets. Since my data contains BLOB data, this method isn't very practical, as each record might grow beyond 1024KB. Is there a way to monitor the actual TCP/IP communication between my client application and the server?
Is it possible to throw a TIdHTTPProxyServer on my client application and monitor data transmission using it?
Update:
Even if that's possible, I'm concerned about the send/receive routine being executed in the main thread, and thus blocking any GUI activity. I read somewhere that I could execute these calls (Refresh and ApplyUpdates) in separate threads, but I haven't got a clue on how to do this.

Delphi and TIdTCPServer.OnExecute: How to correctly merge data

A very simple question I can't seem to find a definitive answer for.
I have a classic TCP Indy server. I send data in chunks. Each data packet is send in 1 or more chunks. When it arrives the OnExecute is triggered one or more times for each packet. More then one client can send data at any given time. How do I know which client / packet am I receiving data for in the OnExecute? I know its a trivial question probably but I want to have a definitive answer.
If you can design the protocol, it could be done like this:
the client starts with a initial command which includes total size and the chunk size
the server OnExecute creates a temporary output file stream and stores file information in the context
the client sends the chunks
the server OnExecute reads chunks (using Indy TCP server blocking read methods with the known chunk length) and appends them to the output stream
The Indy TCP context class can be extended to add custom information for the client connection.

What is the best algorithm/technique to control client connections to the server?

I have over 50 clients connected to one server (low end server, running windows 2003 server), every time there is a power failure or switch failure the clients will disconnect from the server, the server might remain on during this incidents (if power backup is installed), when the clients came back they automatically detect the server and initiate a connection procedure, at this point the server will start dishing out the relevant data to the clients. Its at this point you realize some clients will start freezing becouse the server is not quick enough to dish out data and so it blocks the rest of the clients.
I have implemented a crude method to control this client storm but i was asking if guys out there have better algorithms to perform this kind of task.
NB: Am using Asta sockets components on a delphi application, but i dont mind examples from different fields,
Similar to network collision-detection protocols, perhaps clients could wait a random period of time before initiating their connection at startup?
In addition to the random startup delay suggested by Bremen, implement some sort of "too busy; try again later" message in your protocol. Rejecting a client with a short message should not be a problem for 50, 100, or even 1000 clients. Have the clients respond by doing a random delay and retrying + exponential backoff.
The solution depends on your preferences as well. Is it ok for you to drop down the connections request or send busy message?
Another option can be that you start sending data to the clients in sort of roundrobin manner. To this end you can have different threads responsible for sending data to different clients. Advantage of this case can be that none of the clients will be starved.

Resources