Let’s take a break from the lecturing and get back to our first love and the reason for doing all of this: code.
“How do I send a file?” is a common question on the ØMQ mailing lists. Not surprisingly, file transfer is perhaps the oldest and most obvious type of messaging. Sending files around networks has lots of use cases, apart from annoying the copyright cartels. ØMQ is very good out of the box at sending events and tasks, but less good at sending files.
I’ve promised, for a year or two, to write a proper explanation. Here’s a gratuitous piece of information to brighten your morning: the word “proper” comes from the archaic French propre, which means “clean.” English common folk in the Dark Ages, not being familiar with hot water and soap, changed the word to mean “foreign” or “upper-class,” as in “that’s proper food!”; later it came to mean just “real,” as in “that’s a proper mess you’ve gotten us into!”
So, file transfer. There are several reasons why you can’t just pick up a random file, blindfold it, and shove it whole into a message. The most obvious reason is that despite decades of determined growth in RAM sizes (and who among us old-timers doesn’t fondly remember saving up for that 1,024-byte memory extension card?!), disk sizes obstinately remain much larger. Even if we could send a file with one instruction (say, using a system call like sendfile), we’d hit the reality that networks are neither infinitely fast, nor perfectly reliable. After trying to ...