Solved

how to program queue (FIFO)?

Posted on 1998-08-17
7
346 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now