Solved

how to program queue (FIFO)?

Posted on 1998-08-17
7
349 Views
Last Modified: 2010-04-10
I have developed a SocketServer for accessing my remote controlled WebCam.
Now I need a queue to administrate access.
Please, can someone post me code for this queue ?

In case a client logs in, connection to SocketServer is established and he can control my WebCam.
Conditions:
- Only the "first" client is allowed to control it (others have to wait until first "hang up")
- After 2 min., connection should be interrupted and next client in list is allowed to control the Cam, and so on...
- elements have to be identified by IP-Adress of client (in case say #4 don't want to wait and disconnects, it has to be removed from list of course)

What I need is simply the queue...! doesn't matter if FIFO or some kind of array...I dunno what's better/easier here.

I've reposted this Q coz there was no feedback at all =:-(

I JUST NEED CODE OF A KIND OF A QUEUE:
Inserting an element, removing an element...where the elements are identified by something like an IP-Adress or another identifier.

If you need more detailed info, let me know.

Best regards
-Stavi-
0
Comment
Question by:mitrakis
  • 5
7 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 150 total points
ID: 1170505
Just use the Standard C++ queue template class.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1170506
To use the C++ queueu you need to include the <queue.h> include file.  You will need to create a class, structure, or type to store the information you want in each item the queue.  Say that type is called.  QueueItem, you can then create a queue to store items of that type usign

queue<QueueItem> AQueue;
0
 
LVL 22

Expert Comment

by:nietod
ID: 1170507
You place an item on the queue using the push() procedure like

AQueue.push(NewItem);

You can test to see if there are any items in the queue with the empty() procedure, like

if (AQueue.empty()) ....

You can access the first item in the queue with the top() procedure like

QueueItem CurrentItem = AQueue.top();

You can remove the first item from the queue with the pop() procedure like

AQueue.pop();

Let me know if you have any questions.
0
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 
LVL 3

Author Comment

by:mitrakis
ID: 1170508
THX...now I'm on the way home...I'll check back tomorrow and let you know.

Unfortunately, I solved this queue prob by myself (don't worry...you'll be credited) but now I have a "security violation" regarding my JavaApplet.
Maybe you have any experiences in Java ?...then I'll post my prob here tomorrow (I know that this is the wrong topic, but anyway)

Best regards
-Stavi-

BTW:
Why the hell does the system offer me to reject "MWORMLEY'S" proposed answer ?
nietod, any idea ?...is this another nickname of you ?...or just an error in EE's database ?
0
 
LVL 22

Expert Comment

by:nietod
ID: 1170509
I don't know anything about java, but it is similar to C++, so I can look it over.  .

I'm not sure what you mean about mwormely's answer.  (since this is your question, you get additional stuff on the page that I don't get.)  Is that what it says for this question?  The message that says the name of the expert that answers is new as of this weekend.  Perhaps they have a bug in it.  If so, that is, if you don't see my name listed in the message on this question, don't accept the answer yet.  Post a 0 point question in the customer service topic area (there is a link at the bottom-right corner of the EE home page).that explains the problem.  Let them know that you are leaving the question open so they can see the problem.  
0
 
LVL 2

Expert Comment

by:VEngineer
ID: 1170510

Just for future reference..
to use the Standard Library's queue,

it's:  #include <queue>
not:   #include <queue.h>

0
 
LVL 22

Expert Comment

by:nietod
ID: 1170511
true.  I can never keep that straight.
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question