Creating a listener

Posted on 2009-07-07
Last Modified: 2012-05-07

in my application I need to write a custom listener. Could you please help me to start? I've never wrote something like that. Are there any classes in C++ which I could reuse, do you know some other relevant resources? Thank you in advance!
Question by:StraySod
LVL 12

Expert Comment

Comment Utility
What kind of listener?
LVL 39

Expert Comment

Comment Utility
Do you mean a listener for clients in socket programming?
LVL 40

Accepted Solution

mrjoltcola earned 250 total points
Comment Utility
In standard C++ there are no "standard" listener classes. You will be using sockets either way. You can get an API that has implemented TCP client / server classes.

IP*Works makes it easy

Also Chilkat

Since you did not specificy a platform, I cannot tell much more except on Windows you will be using winsock capability in your project.
On UNIX you use "Berkeley sockets" API.

Start here:

Also look online for UNIX Network Programming by W. RIchard Stevens, it is the classic standby and still the best. Even if not using UNIX, it covers the sockets API in extreme detail and most samples will compile on Windows.

Essentially, for a server, you do the following:

while(true) {
   accept()   // new connection
   service connection

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

LVL 40

Assisted Solution

evilrix earned 250 total points
Comment Utility
Are you trying to implement an observer pattern?

If so try this tutorial: "Implementing the Observer Pattern in C++ - Part 1"

Author Closing Comment

Comment Utility
Thank you. Your comment was helpful
LVL 40

Expert Comment

Comment Utility
I'm slightly confused as the two selected answer are, mostly, unrelated.

Author Comment

Comment Utility
It's because I'm only doing a research, not implementing yet and both answers helped me to understand some concepts. I'm sure it's fair to split points the way I did it in this case :) Thank you again

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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 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.

772 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

11 Experts available now in Live!

Get 1:1 Help Now