[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Checking if TCPSession made successful connection
From: |
Tor Arvid Lund |
Subject: |
Checking if TCPSession made successful connection |
Date: |
Fri, 27 Feb 2004 22:30:30 +0100 |
User-agent: |
Mozilla Thunderbird 0.5+ (X11/20040209) |
Hello,
I cannot figure out how to do this right. In the client code below, I've
made a very simple class extending TCPSession. When called with an
invalid hostname or port, the Thread is never spawned, it seems.
So, my question is: how can I check whether the TCPSession failes its
connection or not? I would like to print "bad hostname", or "connection
refused on port <port>" appropriately.
#include <cc++/socket.h>
#include <iostream>
using namespace ost;
using namespace std;
class mySession : public TCPSession
{
public:
void run() {cout << "Thread running" << endl;}
void final() {cout << "mySession exiting" << endl;}
mySession(InetHostAddress host, int port) : TCPSession(host, port)
{ start(); }
};
int main(int argc, char **argv)
{
const char *host = argv[1];
const int port = atoi(argv[2]);
mySession session(host, port);
Thread::sleep(2000);
return 0;
}
--
Tor Arvid Lund ,''`.
http://totto.homelinux.net : :' :
GnuPG key ID: 0xF335ED1E `. `'
find it at pgp.mit.edu `-
signature.asc
Description: OpenPGP digital signature
- Checking if TCPSession made successful connection,
Tor Arvid Lund <=