0

I'm currently working on transitioning a small console application to a TCP server / client application. The client will connect to the server via any Telnet client, and the server will replicate the standard console interface for each Telnet connection.

I started looking into doing this using the techniques I've learned from Beej's guide to network programming -- accepting the connection and then using fork() to separate it into its own process.

However, I would prefer to maintain my use of streaming IO (the original console application uses cin / cout, using similar functions for the networking logic would make the conversion process much simpler).

I've discovered the TCPStream class, hiding within sockets.h (http://www.gnutelephony.org/doxy/bayonne2/a00215.html)

It appears this class will allow me to use the server with streaming IO. However, I can't find a single example of using this class, nor can I find an explanation as to how to use fork() with it.

Any ideas? Thanks in advance for any help.

1 Answer 1

1

I think you are confusing the trees for the forest. One socket class is such a small part of what you need to do overall that it is not worth focusing on that.

If your objective is just to get your project working then just use an existing framework rather than trying to pull individual classes out of a large project. POCO has a TCPServer class that will do 90% of the work for you. QT, ACE and others have similar classes. There is not a huge amount of documentation on POCO but they do cover TCPServer pretty well and you can learn a lot from reading the source code if that is really where your interest lies.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the information on POCO's TCPServer class. It looks very useful and is well structured in comparison to the other TCPServer libraries I've used before. I suppose I should have been clearer in my question -- although I appreciate alternatives, I'm still wondering... how can this TCPStream class (in sockets.h) be used?
@BSchlinker - Not entirely what you are asking. Either you are going to have to download and compile the entire Bayonne project, include the appropriate headers in your source and link against its libraries...or pull out the source and incorporate it into your own. The latter is not as simple as just using the header file; you need the corresponding cpp file code plus all the code for the objects it inherits from, objects it expects as parameters, typedefs, exceptions, etc. A big PITA if you ask me.
@BSchlinker - If you just want to know how to make the appropriate class calls I didn't find any examples either so you need to puzzle it out from the API docs. All in all a lot of aggrevation just to use stream operators.
@BSchlinker - Take a look at Sockets++ at cs.utexas.edu/users/lavender/courses/socket++ I was struggling to remember what package emphasized the iostream interface and finally remembered. I think it might meet your needs and save you a lot of aggravation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.