Hi all,
I'm need to create a library or class which will open a net connection and communicate with a news server. Yes, I need to create it myself.
Anyone got any good points to where to start? Using C++. Non-negotiable (one day universities will teach the Open Source Community way...)
Thanks.
I'm need to create a library or class which will open a net connection and communicate with a news server. Yes, I need to create it myself.
Hate to say this, but it might not be the news reader's place to start opening and closing internet connections. Most people have their own ways of doing this, and you can't know for sure how somebody's doing it.
What I'd do to be honest is ask the user how to dial up - pretty much everyone I know uses 'pppon' and 'pppoff' or something similar, so you could just fork and execute whatever the user says in your config screens. It'd look a little like this:
#include <sys/types.h> #include <sys/wait.h>
function connect(string pppon) { pid_t pid; if ( pid = fork() ) { // parent. in real life, you'll almost certainly want to // on here and wait for the child later, because // otherwise you'll stop processing your message queues. // best way to do this might be to either store the pid // somewhere useful, and wait for it before you try to // actually connect to the server, or you could register // a signal handler on SIGCHLD and reap the child process // there int status; waitpid(pid, &status, 0); } else { // child - execute the specified program // in reality you need to set ARGV[0] to be // the name of the program, but I can't think // of a dead-obvious way of doing that simply, // so I'll leave that as something for you to // work out. execvp(pppon.c_str(),NULL); } }
Warning: The above code will almost certainly not work.
Anyone got any good points to where to start? Using C++. Non-negotiable (one day universities will teach the Open Source Community way...)
Now might be a time to point out to them that they're not gods, and can't set the future any more than you or I. I'm not bitter. ;-)
HTH
Paul
[ This email came to you via the Anglian Linux User Group list ] [ If you only wish to recieve event announcements, email the ] [ SUBJECTs of "unsubscribe alug" and "subscribe alug-announce" ] [ to listserver@stu.uea.ac.uk -- We do need your support, tho' ]
On 04-Jan-00 jg@cyberstorm.demon.co.uk wrote:
Hi all,
I'm need to create a library or class which will open a net connection and communicate with a news server. Yes, I need to create it myself.
What exactly are you after ?
Is the network already connected ? If yes then you just need to open a tcp/ip socket. If no, then its going to be much harder and may depend on the way the user normally starts their ppp connection.
Peter.
---------------------------------- E-Mail: Peter Onion Peter.Onion@btinternet.com Date: 05-Jan-00 Time: 15:28:35
This message was sent by XFMail ----------------------------------
[ This email came to you via the Anglian Linux User Group list ] [ If you only wish to recieve event announcements, email the ] [ SUBJECTs of "unsubscribe alug" and "subscribe alug-announce" ] [ to listserver@stu.uea.ac.uk -- We do need your support, tho' ]
On Wed, 5 Jan 2000, Peter Onion wrote:
On 04-Jan-00 jg@cyberstorm.demon.co.uk wrote:
Hi all,
I'm need to create a library or class which will open a net connection and communicate with a news server. Yes, I need to create it myself.
What exactly are you after ?
OK, my question was based on the assumption that the user had configured the software either to do 'live' communications or store the messages locally for later posting ('on-connect', etc).
Either way I need to connect to a news server to read/post.
Is the network already connected ? If yes then you just need to open a tcp/ip socket. If no, then its going to be much harder and may depend on the way the user normally starts their ppp connection.
If it's ppp-script based for connection, then I could simply be run with a command-line arguement which would stop the main app from loading and simply run the bit to exchange views with the server. Of course this way I'd need to check about multiple copies running which could be a pig (I could grep a ps I suppose).
On 05-Jan-00 jg@cyberstorm.demon.co.uk wrote:
On Wed, 5 Jan 2000, Peter Onion wrote:
On 04-Jan-00 jg@cyberstorm.demon.co.uk wrote:
Hi all,
I'm need to create a library or class which will open a net connection and communicate with a news server. Yes, I need to create it myself.
What exactly are you after ?
OK, my question was based on the assumption that the user had configured the software either to do 'live' communications or store the messages locally for later posting ('on-connect', etc).
Either way I need to connect to a news server to read/post.
Is the network already connected ? If yes then you just need to open a tcp/ip socket. If no, then its going to be much harder and may depend on the way the user normally starts their ppp connection.
If it's ppp-script based for connection, then I could simply be run with a
^^ ^^-- Don't you know ??? You either need to produce a solution which will work with all methods of setting up ppp or NONE and tell the user to set the link up before running your application.
So there are two areas you need to look at: 1) TCP/IP socket based communicaions 2) the Network News Transport Protocol (NNTP) rfc0977
A good starting point would be to look at the source code for your fave news reader.....
Peter
---------------------------------- E-Mail: Peter Onion Peter.Onion@btinternet.com Date: 06-Jan-00 Time: 08:01:32
This message was sent by XFMail ----------------------------------
[ This email came to you via the Anglian Linux User Group list ] [ If you only wish to recieve event announcements, email the ] [ SUBJECTs of "unsubscribe alug" and "subscribe alug-announce" ] [ to listserver@stu.uea.ac.uk -- We do need your support, tho' ]