I have always been interesting in becoming more fluent in popular GNU/Linux network programming. So I am researching low-level tutorials, as well as how network programming is done with a popular IM program: pidgin.
My interest is in two parts. The 1st part is to better understand the low level socket communication. The 2nd part is to understand how pidgin interacts with libpurple for handling the interactions of messages via sockets in libpurple (polling vs listeners and such).
For the 1st part
----------------------
For the low-level network programming:
http://www.linuxjournal.com/article/2333 http://www.linuxhowtos.org/C_C++/socket.htm For programming using gtk:
http://library.gnome.org/devel/gtk-tutorial/stable/book1.htmlhttp://library.gnome.org/devel/gnet/stable/gnet-tcp.html For how it is done in pidgin:
http://developer.pidgin.im/wiki/WhatIsLibpurplehttp://libpurple.com/writing-your-first-instant-messaging-program/ In teaching myself about sockets, needed self-refreshers on many of the basics:
typedefs
sockets (via "man sockets")
------------------------------------------
It is possible to do non-blocking I/O on sockets by setting the O_NONBLOCK flag on a socket file descriptor using fcntl(2). Then all operations that would block will (usually) return with EAGAIN (operation should be retried later); connect(2) will return EINPROGRESS error. The user can then wait for various events via poll(2) or select(2).
An alternative to poll(2) and select(2) is to let the kernel inform the application about events via a SIGIO signal. For that the O_ASYNC flag must be set on a socket file descriptor via fcntl(2) and a valid signal handler for SIGIO must be installed via sigaction(2).
/usr/include/sys/ioctl.h
http://linux.die.net/man/3/getaddrinfohttp://linux.die.net/man/2/setsockopthttp://linux.die.net/man/2/fcntlhttp://linux.die.net/man/2/open For the low level stuff of how libpurple actually uses sockets and such:
libpurple/network.h
libpurple/network.c
The function purple_network_do_listen seems to do the heavy lifting.
static PurpleNetworkListenData * purple_network_do_listen(unsigned short port, int socket_family, int socket_type, PurpleNetworkListenCallback cb, gpointer cb_data)
{ ... }
For the 2nd part
-------------------------