Re: Avoiding string break...
- From: Glus Xof <gtglus gmail com>
- To: Piscium <groknok yahoo ie>
- Cc: gtkmm-list gnome org
- Subject: Re: Avoiding string break...
- Date: Tue, 4 May 2010 00:21:56 +0200
2010/5/3 Piscium <groknok yahoo ie>:
> I think you don't need base64 at all. It appears that there is a simple bug in your code where you convert from string object to raw data, or vice-versa.
>
> So the easiest is probably if you post the relevant excerpt of your source code, the bug should be easy to find.
Yes, no problem... thanks,
std::string clear_data;
std::string encrypted_data;
std::string send_data = clear_data+encrypted_data;
gsize to_send = send_data.size();
gsize size = to_send;
/*
* Writing routine excrept
*/
while (to_send > 0)
{
try
{
size = mysocket->send (send_data.c_str(), size);
}
catch (...)
[...]
if (size == 0)
{
std::cerr
<< "Unexpected short write"
<< std::endl;
return false;
}
to_send -= size;
}
/*
* Reading routine excrept
*/
buffer=g_new0(gchar,999999);
try
{
messlen = mysocket->receive (buffer, 999999);
}
catch (...)
{
std::cerr
<< Glib::ustring::compose ("Error receiving from socket: %1",
error.what())
<< std::endl;
return "";
}
if (messlen==0)
{
mysocket->close();
return "";
}
else
{
buffer[messlen]='\0';
std::string received_data (buffer);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]