Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how to program queue (FIFO)?

Posted on 1998-08-17
7
Medium Priority
?
366 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 300 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

618 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