Re: Avoiding string break...



Hi guys,

Finally solved !

--- Changes in lt_server.cc

bool send_my_message (std::string & s_mymess)
{
	const gchar * s_message = g_strdup_printf("%s\0", s_mymess.data());
	gssize to_send = s_mymess.size();

	gssize size = 0;

	while (to_send > 0)
	{
		try
		{
			size = socket->send (s_message, to_send);
		}

[...]

with this,

bool send_my_message (std::string & s_mymess)
{
	gssize to_send = s_mymess.size();
	gssize size = 0;

	while (to_send > 0)
	{
		try
		{
			size=client_socket->send (s_mymess.data(),to_send);
		}
[...]


--- Changes in lt_client.cc

std::string recv_my_message()
{
    gchar * r_message = g_new0(gchar,999999);
    gint messlen=0;

    try
    {
		messlen = socket->receive (r_message, 999999);
[...]
        std::string r_string (r_message);

        return r_string;
	}
}

with this,

std::string recv_my_message()
{
    gchar * r_message = g_new0(gchar, 999999);
    gint messlen=0;

    try
    {
		messlen = socket->receive (r_message, 999999);
[...]

        std::string r_string (r_message, messlen);

        g_free (r_message);

        return r_string;
	}
}

Thanks to all for the patience...
and thanks also to Piscium, Mark Roberts, José Alburquerque, Michi7x7,
Robert Pearce and Chris Vine.

Glus


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]