Hi ALL,
I have encountered this error, and
would like to program a win32 FTP client with asio lib.
In asio examples I
reffenrenced at the 'Services(logger program)'.
Could you help me
?
I appriciate any suggestion.
Thank all,
Yasuhiko Yoshimura
(Japan)
An accsess violence occured at the below ===>>
point.
win_mutex.hpp:line
125:
------------------------------------------------------------------------
Then
variable values are:
&crit_section_
0xcdcdcdcd
this 0xcdcdcdcd
(boost::noncopyable_::noncopyable)
// Locking must be
performed in a separate function to lock() since the
// compiler does
not support the use of structured exceptions and C++
// exceptions in
the same function.
int do_lock()
{
__try
{
===>>
::EnterCriticalSection(&crit_section_);
}
__except(GetExceptionCode() ==
STATUS_INVALID_HANDLE
||
GetExceptionCode() ==
STATUS_NO_MEMORY
?
EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
{
if (GetExceptionCode() ==
STATUS_NO_MEMORY)
return
ERROR_OUTOFMEMORY;
return
ERROR_INVALID_HANDLE;
}
return 0;
}
------------------------------------------------------------------------
Here
are my codes below.
And error point was ===>>
------------------------------------------------------------------------
using
boost::asio::ip::tcp;
class ftp_client_dtp
: public
boost::enable_shared_from_this<ftp_client_dtp>
{
public:
typedef
boost::shared_ptr<ftp_client_dtp> pointer;
static
pointer create(boost::asio::io_service& io_service)
{
return pointer(new
ftp_client_dtp(io_service));
}
tcp::socket&
socket()
{
return
*work_socket_;
}
...
void
start()
{
work_thread_.reset(new
boost::thread(
boost::bind(&boost::asio::io_service::run,
&work_io_service_)));
// Start an asynchronous resolve
to translate the server and service names
// into a list of
endpoints.
tcp::resolver::query query(sip_,
sport_);
work_resolver_->async_resolve(query,
boost::bind(&ftp_client_dtp::handle_resolve,
shared_from_this(),
boost::asio::placeholders::error,
boost::asio::placeholders::iterator));
}
void
close()
{
work_io_service_.post(boost::bind(&ftp_client_dtp::do_close,
shared_from_this()));
}
ftp_client_dtp(boost::asio::io_service&
io_service)
: work_io_service_(),
work_resolver_(new
boost::asio::ip::tcp::resolver(work_io_service_)),
work_socket_(new
boost::asio::ip::tcp::socket(work_io_service_))
===>>
{
}
~ftp_client_dtp()
{
work_.reset();
if (work_thread_)
work_thread_->join();
}
private:
std::ofstream
f;
void handle_resolve(const boost::system::error_code&
err,
tcp::resolver::iterator endpoint_iterator)
{
...
}
void handle_connect(const boost::system::error_code&
err,
tcp::resolver::iterator endpoint_iterator)
{
...
}
void handle_read_content(const
boost::system::error_code& err)
{
...
}
void do_close()
{
work_socket_->close();
}
std::string sip_,
sport_, scurrentpath_, sfilename_;
boost::asio::streambuf
request_;
boost::asio::streambuf
response_;
boost::scoped_ptr<boost::asio::ip::tcp::resolver>
work_resolver_;
boost::scoped_ptr<boost::asio::ip::tcp::socket>
work_socket_;
boost::asio::io_service
work_io_service_;
boost::scoped_ptr<boost::asio::io_service::work>
work_;
boost::scoped_ptr<boost::thread>
work_thread_;
};
ftp_client_dtp::pointer
new_connection_;
new_connection_ =
ftp_client_dtp::create(io_service_);
new_connection_->start();
------------------------------------------------------------------------
Thank all,
Yasuhiko Yoshimura
(Japan)