Re: Glib::IOChannel in sockets... (2)
- From: Glus Xof <gtglus gmail com>
- To: Krzesimir Nowak <qdlacz gmail com>
- Cc: Chris Vine <chris cvine freeserve co uk>, gtkmm-list gnome org
- Subject: Re: Glib::IOChannel in sockets... (2)
- Date: Tue, 22 Dec 2009 15:58:47 +0100
2009/12/22 Krzesimir Nowak <qdlacz gmail com>:
> On Tue, 2009-12-22 at 10:58 +0100, Glus Xof wrote:
>> Hello guys,
>>
>> 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()...
>>
>> Thanks to all,
>>
>> Glus
>
> Hi,
>
> you probably misunderstood IOChannels. You have to create a socket
> first, then bind/accept/whatever and then create IOChannel with
> create_from_fd static method (or else). GIOChannels were created
> probably for portable I/O operations like reading from and writing to,
> since these are most often use cases of files/sockets/pipes. But
> creating them was meant to be written in some sort of backend code like
> this:
>
> Glib::RefPtr<Glib::IOChannel> get_channel()
> {
> #ifdef WINDOWS
> // create a socket in windows and obtain its descriptor
> int s_fd = something();
> Glib::RefPtr<Glib::IOChannel> my_channel =
> Glib::IOChannel::create_from_win32_socket(s_fd);
> #else
> int s_fd = socket(...);
> Glib::RefPtr<Glib::IOChannel> my_channel =
> Glib::IOChannel::create_from_fd(s_fd);
> #endif
> return my_channel;
> }
Thanks, Krzesimir,
I think that now it's a little more clear...
> For sockets - use GSocket. But C++ wrapper of GSocket just hit the
> unstable version of Giomm, so you'll probably have to use C API.
I just looked up GSocket & seems interesting... the stable GIOmm will
be released soon ?
Glus
> Krzesimir
>
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]