joakim | 6 Feb 15:20
Picon

SSL ip address

How do I get the ip address of the remote endpoint of a socket of type boost::asio::ssl::stream<boost::asio::ip::tcp::socket> ?
 
Regards,
Jocke
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
asio-users mailing list
asio-users@...
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
U.Mutlu | 9 Feb 09:08

Re: SSL ip address

joakim@... wrote, On 02/06/12 15:20:
> How do I get the ip address of the remote endpoint of a socket of type
boost::asio::ssl::stream<boost::asio::ip::tcp::socket>  ?

  ssl_socket s;
  ...
  const string sClientIP   = s.lowest_layer().remote_endpoint().address().to_string();
  const size_t uClientPort = s.lowest_layer().remote_endpoint().port();
  const string sServerIP   = s.lowest_layer().local_endpoint().address().to_string();
  const size_t uServerPort = s.lowest_layer().local_endpoint().port();

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
asio-users mailing list
asio-users@...
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio

joakim | 9 Feb 10:46
Picon

Re: SSL ip address

Thanks! 

-----Original Message-----
From: U.Mutlu [mailto:for-gmane@...] 
Sent: den 9 februari 2012 09:09
To: asio-users@...
Subject: Re: [asio-users] SSL ip address

joakim@... wrote, On 02/06/12 15:20:
> How do I get the ip address of the remote endpoint of a socket of type
boost::asio::ssl::stream<boost::asio::ip::tcp::socket>  ?

  ssl_socket s;
  ...
  const string sClientIP   = s.lowest_layer().remote_endpoint().address().to_string();
  const size_t uClientPort = s.lowest_layer().remote_endpoint().port();
  const string sServerIP   = s.lowest_layer().local_endpoint().address().to_string();
  const size_t uServerPort = s.lowest_layer().local_endpoint().port();

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization -
but cloud computing also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
asio-users mailing list
asio-users@...
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
asio-users mailing list
asio-users@...
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio

Darren Cook | 10 Feb 10:47

ip::address::from_string() not working

ip::address's from_string() function does not seem to be working; it
gives me 0.0.0.0 whatever string I pass.

A very minimal reproducible example below, it outputs:
  Set host to 0.0.0.0

I'm using boost 1.40 (ubuntu 10.04). Google is strangely quiet; so I
guess I'm doing something wrong??

Darren

//Compile and run with "g++ test.cpp -lboost_system;./a.out"

#include <iostream>
#include <boost/asio.hpp>

int main(int argc, char* argv[])
{
    boost::asio::ip::address host;
    host.from_string("127.0.0.1");
    std::cout<<"Set host to "<<host<<"\n";
    return 0;
}

-- 
Darren Cook, Software Researcher/Developer

http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
asio-users mailing list
asio-users@...
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio

niXman | 10 Feb 11:22
Picon
Gravatar

Re: ip::address::from_string() not working

'boost::asio::ip::address::from_string()' is a static member function:
http://www.boost.org/doc/libs/1_48_0/doc/html/boost_asio/reference/ip__address/from_string.html

usage:
#include <iostream>
#include <boost/asio.hpp>

int main(int argc, char* argv[])
{
   boost::asio::ip::address host =
boost::asio::ip::address::from_string("127.0.0.1");
   std::cout<<"Set host to "<<host<<"\n";
   return 0;
}

http://liveworkspace.org/code/eda650ea2820edf01b09cb2594856ef5

Regards.
niXman.

2012/2/10 Darren Cook <darren <at> dcook.org>:
> ip::address's from_string() function does not seem to be working; it
> gives me 0.0.0.0 whatever string I pass.
>
> A very minimal reproducible example below, it outputs:
>  Set host to 0.0.0.0
>
> I'm using boost 1.40 (ubuntu 10.04). Google is strangely quiet; so I
> guess I'm doing something wrong??
>
> Darren
>
>
> //Compile and run with "g++ test.cpp -lboost_system;./a.out"
>
> #include <iostream>
> #include <boost/asio.hpp>
>
> int main(int argc, char* argv[])
> {
>    boost::asio::ip::address host;
>    host.from_string("127.0.0.1");
>    std::cout<<"Set host to "<<host<<"\n";
>    return 0;
> }
>
>
> --
> Darren Cook, Software Researcher/Developer
>
> http://dcook.org/work/ (About me and my work)
> http://dcook.org/blogs.html (My blogs and articles)
>
> ------------------------------------------------------------------------------
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> asio-users mailing list
> asio-users <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/asio-users
> _______________________________________________
> Using Asio? List your project at
> http://think-async.com/Asio/WhoIsUsingAsio

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
asio-users mailing list
asio-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
Pierre Belzile | 11 Feb 01:47
Favicon

Re: Working in boost 1.47.0, broken in 1.48?

Two weeks ago I posted a message about a behavior change in asio in boost 1.48. Since then I have learned more about the problem and was able to reproduce it using  a simple test program that I'm attaching.

The bottom line:
* works fine in 1.47
* works fine in 1.48 when defining BOOST_ASIO_DISABLE_EPOLL
* misses messages in 1.48 with EPOLL.

From what I can tell, the server receives a TCP message, the low-level stack acknowledges it to the client but the async callback does not occur. I suspect that a race condition with the closing of another socket after an inactivity timeout is causing a missed edge with the edge-triggered epoll.

To run this program, you start an instance with argument "s" (server) and on the same machine another instance with argument "c" (client). After a few iterations, the client always dies in my environment with the message:
  terminate called after throwing an instance of 'std::runtime_error'
  what():  Client::read_reply, unexpected: Connection reset by peer

This message occurs on the client side as my inactivity timer on the server side closes the connection because the callback has not occurred within the allowed 10 seconds. 

My environment:
* Linux 2.6.32-131.21.1.el6.x86_64 #1 SMP Tue Nov 22 14:15:09 CST 2011 x86_64 x86_64 x86_64 GNU/Linux
* gcc version 4.4.5 20110214 (Red Hat 4.4.5-6) (GCC)
* quad dual core

I compile with:
 g++ -O3   -I /usr/local/boost_1.48.0/include test.cc -L /usr/local/boost_1.48.0/lib64 -l boost_system-mt -l boost_thread-mt

Attachment (test.cc): text/x-c++src, 8 KiB
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
asio-users mailing list
asio-users@...
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
Igor R | 11 Feb 19:25
Picon

Re: Working in boost 1.47.0, broken in 1.48?

> Two weeks ago I posted a message about a behavior change in asio in boost
> 1.48. Since then I have learned more about the problem and was able to
> reproduce it using  a simple test program that I'm attaching.
>
> The bottom line:
> * works fine in 1.47
> * works fine in 1.48 when defining BOOST_ASIO_DISABLE_EPOLL
> * misses messages in 1.48 with EPOLL.
>
> From what I can tell, the server receives a TCP message, the low-level stack
> acknowledges it to the client but the async callback does not occur. I
> suspect that a race condition with the closing of another socket after an
> inactivity timeout is causing a missed edge with the edge-triggered epoll.

Maybe I miss something, but at a glance it seems that you've got race
conditions in your own code. Note that the completion handlers in the
server code might be executed in different threads, because you run
io_service::run in 4 threads.

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
asio-users mailing list
asio-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio
Darren Cook | 13 Feb 06:17

Re: ip::address::from_string() not working

> ...
>    boost::asio::ip::address host =
> boost::asio::ip::address::from_string("127.0.0.1");

Thanks niXman, that worked! (I had tried using it statically, after
finding an example on the web somewhere, but I got a segmentation error;
it must have been an unlucky coincidence.)

Darren

-- 
Darren Cook, Software Researcher/Developer

http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
asio-users mailing list
asio-users@...
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio

Pierre Belzile | 13 Feb 21:25
Favicon

Re: Working in boost 1.47.0, broken in 1.48?

Igor,

I've wrapped all the callbacks into a "strand" instance to prevent those 
multithread contention issues. It helps to keep in mind that the code 
works endlessly in 1.47 or 1.48 without epoll.

Pierre

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
asio-users mailing list
asio-users@...
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio

Andriy Tylychko | 15 Feb 19:11
Picon

TCP SSL socket: async_write of multi-buffers fails in Boost v.1.48

I don’t know if this problem was already reported.

 

I noticed a problem writing asynchronously multi-buffers to TCP SSL socket. Example:

 

// data to send, protocol is [packet size: 4 bytes][packet: packet_size bytes]
std::vector
<char> packet = ...;
uint32_t packet_size = packet.size();
// prepare buffers
boost::array<boost::asio::const_buffer,
2> bufs = {{boost::asio::buffer(&packet_size, sizeof(packet_size)), boost::asio::buffer(packet)}};
// send multi buffers by single call
boost::asio::async_write(socket, bufs, ...);

 

Sending separately “packet_size” and “packet” in this example works around the problem. Tried on Boost v.1.47 - works fine. Tried with usual TCP socket (not SSL one) - works fine. The same on both Linux and Windows.

 

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
asio-users mailing list
asio-users@...
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio

Gmane