buffer or que implementation

  • Thread starter Thread starter Nikolay Petrov
  • Start date Start date
N

Nikolay Petrov

I need to write tcp client/server program.
The client should connect to server at specified intervals and download some
data.
The data is collection of strings.
What I don't know how to do is how to implement some kind of queue, so this
string as queued at server, then client connects, get them, clear them from
queue and process them. The client should interpret these string as separate
objects, not as an whole.
Forget the string part. The data can be of any type. I need an idea how to
implement queuing method.

TIA
 
Nikolay Petrov said:
I need to write tcp client/server program.
The client should connect to server at specified intervals and download
some data. The data is collection of strings.
What I don't know how to do is how to implement some kind of queue,
so this string as queued at server, then client connects, get them, clear
them from queue and process them. The client should interpret these
string as separate objects, not as an whole.

The simplest way you could do this would be to hold the "queue" as a
text file on the server (this way, it doesn't matter how long the queue
builds up for - what can you do if you rely on the server holding the
queue in memory and the server process crashes?). This file can use
whatever delimiters you might need to identify the structure(s) it contains.

The Client process connects to a socket on the server.
The Server process (probably in a separate thread) reads the entire
queue file, writes it back to the Client's socket, then throws the file
away.
The Client can then interpret the data anyway it needs to.

HTH,
Phill W.
 
You may also want to look into the Message Queueing service on the
server. Your client can connect to the message queue and retrieve the
object from the queue.

chris
 
I am not sure that i can connect to Message Queuing service form client.
It's is going to be an Internet application.
 
In my case I don't care if server craches.



Phill. W said:
The simplest way you could do this would be to hold the "queue" as a
text file on the server (this way, it doesn't matter how long the queue
builds up for - what can you do if you rely on the server holding the
queue in memory and the server process crashes?). This file can use
whatever delimiters you might need to identify the structure(s) it
contains.

The Client process connects to a socket on the server.
The Server process (probably in a separate thread) reads the entire
queue file, writes it back to the Client's socket, then throws the file
away.
The Client can then interpret the data anyway it needs to.

HTH,
Phill W.
 
Are there multiple clients that will connect and do each of them need their
own queue state?

I would create a web service to do this. Pass in the Client ID and the last
time they connected. Save the queue in a database with an incrementing
counter. Client connects, gets all data after the last time he connected.

Does this help?
Chris
 
Using database or file to store is too much of over head. I just need in
memory queue. For now the client is one. If there are more, there are going
to be different queues for every client.
What I mainly can't figure out if i store the date in array or something,
what happens when cleint start reading data and in the same moment a new
piece of data is added. There must be some way to queue things in .NET.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top