Overview
Features
Download
Documentation
Community
Add-Ons & Services

SecureStreamSocketImpl connectNB does not work

Please post support and help requests here.

SecureStreamSocketImpl connectNB does not work

Postby eran » 13 Jun 2007, 22:56

This works:


std::string buffer = "<?xml version='1.0'?><stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' to='gmail.com'>";
Poco::AutoPtr<Poco::Net::SecureStreamSocketImpl> socket(new Poco::Net::SecureStreamSocketImpl);
try
{
socket->connect(Poco::Net::SocketAddress("talk.google.com", 5223));

Poco::Thread::sleep(1000);

int sent = socket->sendBytes(buffer.c_str(), int(buffer.size()));

Poco::Thread::sleep(1000);

char buf[1024];
int got = socket->receiveBytes(buf, 1023);

Poco::Thread::sleep(1000);

buffer = "<iq id='auth1' type='get' to='gmail.com'><query xmlns='jabber:iq:auth'><username>nouncer</username></query></iq>";
sent = socket->sendBytes(buffer.c_str(), int(buffer.size()));

Poco::Thread::sleep(1000);

got = socket->receiveBytes(buf, 1023);

Poco::Thread::sleep(1000);

}
catch (Poco::Exception& exc)
{
std::cout << exc.displayText());
}


But changing to connectNB blows up. Any ideas?


EHL
eran
 
Posts: 8
Joined: 26 Dec 2006, 04:33
Location: United_States

Re: SecureStreamSocketImpl connectNB does not work

Postby guenter » 18 Jun 2007, 12:14

I'll have Peter look into it.

Günter
guenter
 
Posts: 1110
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: SecureStreamSocketImpl connectNB does not work

Postby peter » 18 Jun 2007, 12:32

>
>
> But changing to connectNB blows up. Any ideas?

Well, if you do a connectNB followed by a 1 second sleep, and then a send,
you have no guarantee that the connection is already established
after the sleep.

Which error do you get back?

br
Peter
>
>
> EHL
peter
 
Posts: 67
Joined: 11 Jul 2006, 16:26
Location: Austria

Re: SecureStreamSocketImpl connectNB does not work

Postby eran » 26 Jun 2007, 16:14

It asserts that the socket handle is already set. Nothing to do with the connection being ready.

EHL
eran
 
Posts: 8
Joined: 26 Dec 2006, 04:33
Location: United_States

Re: Re: SecureStreamSocketImpl connectNB does not work

Postby peter » 27 Jun 2007, 15:05

> It asserts that the socket handle is already set. Nothing to do with the connection being ready.
>
> EHL

Well,
I took your code and tested it on my machine.
It failed exactly once with an IOerror (maybe conincidence?),
but all subsequent tests worked (with connectNB) with the following change:

Change connectNB:

int tmpSocket=0;

BIO_get_fd(_pBIO,&tmpSocket);

poco_assert (-1 != tmpSocket);

setSockfd(tmpSocket);

establishTunnel();

connectSSL(address);

poco_check_ptr (_pSSL);

Remove the first 4 lines before establishTunnel.

br
Peter

peter
 
Posts: 67
Joined: 11 Jul 2006, 16:26
Location: Austria

Re: Re: Re: SecureStreamSocketImpl connectNB does not work

Postby eran » 28 Jun 2007, 15:37

Thanks Peter,

I took a look and I am not sure what you mean by remove the 4 lines. Your code smaple includes them. If this is a bug fix, can you post the entire function after the change? If you cannot reporoduce it, I will email you the source files to try it out.

Thanks,

EHL
eran
 
Posts: 8
Joined: 26 Dec 2006, 04:33
Location: United_States

Re: Re: Re: SecureStreamSocketImpl connectNB does not work

Postby peter » 29 Jun 2007, 17:32

Remove exactly those 4 lines from the function SecureStreamSocketImpl connectNB:

int tmpSocket=0;

BIO_get_fd(_pBIO,&tmpSocket);

poco_assert (-1 != tmpSocket);

setSockfd(tmpSocket);


br
Peter


> > It asserts that the socket handle is already set. Nothing to do with the connection being ready.
> >
> > EHL
>
> Well,
> I took your code and tested it on my machine.
> It failed exactly once with an IOerror (maybe conincidence?),
> but all subsequent tests worked (with connectNB) with the following change:
>
> Change connectNB:
>
> int tmpSocket=0;
>
> BIO_get_fd(_pBIO,&tmpSocket);
>
> poco_assert (-1 != tmpSocket);
>
> setSockfd(tmpSocket);
>
> establishTunnel();
>
> connectSSL(address);
>
> poco_check_ptr (_pSSL);
>
> Remove the first 4 lines before establishTunnel.
>
> br
> Peter
>
>
peter
 
Posts: 67
Joined: 11 Jul 2006, 16:26
Location: Austria

Re: Re: Re: Re: SecureStreamSocketImpl connectNB does not work

Postby eran » 29 Jun 2007, 18:04

Thanks!

Is this going to be an official solution in an upcoming release?

EHL
eran
 
Posts: 8
Joined: 26 Dec 2006, 04:33
Location: United_States

Re: Re: Re: Re: Re: SecureStreamSocketImpl connectNB does not work

Postby peter » 02 Jul 2007, 08:40

> Thanks!
>
> Is this going to be an official solution in an upcoming release?
>
> EHL

Definitely,
thanks for informing us about this bug!

Peter
peter
 
Posts: 67
Joined: 11 Jul 2006, 16:26
Location: Austria


Return to Support

Who is online

Users browsing this forum: No registered users and 3 guests

cron