Re: Glib::IOChannel in sockets... (2)
- From: Glus Xof <gtglus gmail com>
- To: Chris Vine <chris cvine freeserve co uk>
- Cc: gtkmm-list gnome org
- Subject: Re: Glib::IOChannel in sockets... (2)
- Date: Tue, 22 Dec 2009 10:58:17 +0100
Hello guys,
El 21 / desembre / 2009 23:28, Chris Vine
<chris cvine freeserve co uk> ha escrit:
> On Mon, 21 Dec 2009 16:36:57 -0500
> José Alburquerque <jaalburquerque cox net> wrote:
>
>> On Mon, 2009-12-21 at 18:42 +0100, Glus Xof wrote:
>> > Hello guys,
>> >
>> > Some days ago, I wrote,
>> >
>> > 2009/12/17 Glus Xof <gtglus gmail com>:
>> > > Hello guys,
>> > >
>> > > I was unsuccessfully googling, searching for an explanations
>> > > about how to use Glib::IOChannel in case of Sockets: a little
>> > > tutorial, or a code example...
>> >
>> > and I truly need to communicate two proceses running in different
>> > machines (by sockets), both sending & receiving Glib::ustring
>> > values. For the moment, using socket(), bind(), listen(), accept(),
>> > connect()... is enough to interchange std::string values, but I get
>> > "Glib::ConvertError"s with Glib::ustring.
>>
>> Maybe setting the encoding would make a difference.
>>
>> The following excerpt from the Glib::IOChannel docs[1] seems relevant:
>>
>> "Note that IOChannels implement an automatic implicit character set
>> conversion to the data stream, and usually will not pass by default
>> binary data unchanged. To set the encoding of the channel, use e.g.
>> set_encoding("ISO-8859-15"). To set the channel to no encoding, use
>> set_encoding() without any arguments."
>
> Note also that if you are sending UTF-8 over the socket you have no
> right to assume that a read on the socket will always produce a whole
> character (UTF-8 characters can be between 1 and 5 bytes long). If you
> are not doing a read delimited by, say, line ends, you will need to
> reassemble your UTF-8.
>
> If you want some ideas here is a class that will do that for you:
> http://cxx-gtk-utils.cvs.sourceforge.net/viewvc/*checkout*/cxx-gtk-utils/c%2B%2B-gtk-utils/c%2B%2B-gtk-utils/reassembler.h
> http://cxx-gtk-utils.cvs.sourceforge.net/viewvc/*checkout*/cxx-gtk-utils/c%2B%2B-gtk-utils/c%2B%2B-gtk-utils/reassembler.cpp
As for that Mr Albuquerque said, I think that should be possible to
communicate two processes by sockets using Glibmm & Giomm libraries...
"IOChannel aims to provide portable I/O support for files, pipes and
sockets, and to integrate them with the GLib main event loop...."
(http://library.gnome.org/devel/glibmm/stable/classGlib_1_1IOChannel.html)
The problem is that I don't reach to understand how to use them in that sense...
How can I "construct" this channel "a la Glibmm & Giomm" ?...
Which method is the equivalent of socket() (if any) ?
Which method is the equivalent of bind() (if any) ?
Which method is the equivalent of listen ().... and accept()... and connect()...
Is it possible to create a connection based socket connections
suitable to interchange (in both directions) Glib::ustring values,
following the client-server architecture ?
Thanks to all,
Glus
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]