Re: Review of gnio, round 2



On Tue, 2009-05-19 at 07:50 -0400, Dan Winship wrote:
> Alexander Larsson wrote:
> > There is no GLIB_SYSDEF enum thing because there are no such thing in
> > the sockets API. You use getprotobyname, which is wrapped as
> > g_socket_protocol_id_lookup_by_name().
> 
> Hm... actually, it looks like this is implemented pretty lamely in the
> sockets API. There's only a single name<->id mapping (defined by
> getproto* and /etc/protocols), which basically means all socket types
> have to use the same mapping as network sockets do. And the socket()
> docs fall just shy of saying you're allowed to use the IPPROTO_* values
> from netinet/in.h, though it's very strongly implied, and Google code
> search shows "socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)" to be an order
> of magnitude more common than the same with getprotobyname("tcp").
> (Though of course, most people just pass "0".)
> 
> I'd say
> 
> typedef enum {
>   G_SOCKET_PROTOCOL_DEFAULT = 0,
>   G_SOCKET_PROTOCOL_TCP     = 6,
>   G_SOCKET_PROTOCOL_UDP     = 17,
>   G_SOCKET_PROTOCOL_SCTP    = 132
> } GSocketProtocol;
> 
> with the standard "and you can pass other things too" note, and don't
> bother with g_socket_protocol_id_lookup_by_name() (people can use
> getprotobyname if they really want to).

Yeah, i did this.

> (Amusingly, googling SO_KEEPALIVE turns up some really ancient
> discussions in which people suggest that using it is bad because of the
> additional network traffic caused by sending 1 extra packet every two
> hours. Presumably they all had 300 baud modems or something...)

Heh.



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