• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 340
  • Last Modified:

Creating a listener


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!
2 Solutions
What kind of listener?
Do you mean a listener for clients in socket programming?
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: http://en.wikipedia.org/wiki/Berkeley_sockets

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

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

evilrixSenior Software Engineer (Avast)Commented:
Are you trying to implement an observer pattern?

If so try this tutorial: "Implementing the Observer Pattern in C++ - Part 1"
StraySodAuthor Commented:
Thank you. Your comment was helpful
evilrixSenior Software Engineer (Avast)Commented:
I'm slightly confused as the two selected answer are, mostly, unrelated.
StraySodAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now