Solved

how to program queue (FIFO)?

Posted on 1998-08-17
7
357 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

696 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