I am just starting out with Common C++, and I think it's just great. It would be even greater if I'd actually be able to make something work with it. =)
I have tried to begin a large TCP client using TCPSession, but I'm having some problems, so I created a miniature version of my code which doesn't work the way I'd expect.
What it's supposed to do is connect to a given ip:port, and then run the thread, which, according to its Run() method, should print if the connection was successful or not (this might not be the right way to do it, but still, it doesn't print *ANYTHING*).
I also tried playing a bit with overriding Initial(), but it seems that it is not run either.
int main(int argc, char *argv[])
{
if (argc < 3)
{
cerr << "Attempts to open connection using TCPSession, and prints if was successful\n";
cerr << "USAGE: " << argv[0] << " <ip-addr> <port>\n";
exit(-1);
}
TCPSession *session;
session = new OutgoingTcpSession_t((InetHostAddress) argv[1], atoi(argv[2]));
while (!finished);
return 0;
}
Hope you can help,
Avital Oliver.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would also like to add that if I run tcpdump, I see the socket *does* open correctly, and even my ftp server informs me of an incoming connection when I try to connect to port 21.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2000-10-19
I too am having this exact problem. Run is never called, nor is Initial. Things work fine for server TCPStream objects, but not for client TCPStream objects. On Linux, I believe the thread is being killed silently; On Windows, it is being killed and an access violation is being reported.
Any solutions/fixes?
-> Cary
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am just starting out with Common C++, and I think it's just great. It would be even greater if I'd actually be able to make something work with it. =)
I have tried to begin a large TCP client using TCPSession, but I'm having some problems, so I created a miniature version of my code which doesn't work the way I'd expect.
What it's supposed to do is connect to a given ip:port, and then run the thread, which, according to its Run() method, should print if the connection was successful or not (this might not be the right way to do it, but still, it doesn't print *ANYTHING*).
I also tried playing a bit with overriding Initial(), but it seems that it is not run either.
Here is the code:
#include <cc++/socket.h>
#include <iostream.h>
#include <stdlib.h>
class OutgoingTcpSession_t :
public TCPSession
{
private:
void Run();
public:
OutgoingTcpSession_t(InetHostAddress addr, int16 port)
: TCPSession(NULL, addr, port)
{
cout << "Initializer\n";
}
~OutgoingTcpSession_t()
{
}
};
bool finished = false;
void
OutgoingTcpSession_t::Run()
{
cout << "!!!\n";
if (isConnected())
{
cout << "Accepted\n";
finished = true;
}
else
{
cout << "Rejected\n";
finished = true;
}
}
int main(int argc, char *argv[])
{
if (argc < 3)
{
cerr << "Attempts to open connection using TCPSession, and prints if was successful\n";
cerr << "USAGE: " << argv[0] << " <ip-addr> <port>\n";
exit(-1);
}
TCPSession *session;
session = new OutgoingTcpSession_t((InetHostAddress) argv[1], atoi(argv[2]));
while (!finished);
return 0;
}
Hope you can help,
Avital Oliver.
I just wanted to add that I'm running on Slackware Linux with kernel 2.2.13 (sorry, not sure which Slackware version I'm using).
I would also like to add that if I run tcpdump, I see the socket *does* open correctly, and even my ftp server informs me of an incoming connection when I try to connect to port 21.
I too am having this exact problem. Run is never called, nor is Initial. Things work fine for server TCPStream objects, but not for client TCPStream objects. On Linux, I believe the thread is being killed silently; On Windows, it is being killed and an access violation is being reported.
Any solutions/fixes?
-> Cary