C/C++ beanstalk client
C C++ Makefile Shell
Latest commit 851ef51 Nov 2, 2016 @deepfryed committed on GitHub Merge pull request #33 from opengear/makefile-fixes-for-yocto
Makefile fixes for yocto / bitbake
Failed to load latest commit information.
debian version bump to 1.3.0 Sep 10, 2016
docs initial commit - wip Mar 3, 2012
examples Add bs_version function to expose library version Jun 28, 2013
test Added Client#is_connected and version bump to 1.2.0 Nov 6, 2013
.gitignore create versioned sharedlib symlink post build. Jun 6, 2016
README.md remove references to ppa packages. Sep 10, 2016
beanstalk-client.pc improve build and pkgconfig under Open Embedded Oct 22, 2015
beanstalk.c fix formatting & throw connect exception where needed. Sep 10, 2016
beanstalk.cc fix formatting & throw connect exception where needed. Sep 10, 2016
beanstalk.h version bump to 1.3.0 Sep 10, 2016
benchmark.cc Change ids to be int64_t and fix type conversion warnings Jun 17, 2013
makefile use CXX instead of CPP compiler variable Nov 2, 2016


beanstalkd client

C/C++ beanstalkd client that is blocking by default.


sudo make install


The tests need google test installed (libgtest-dev on debian based distros).

sudo apt-get install libgtest-dev

Since the package does not come with a pre-build library, you need to build and install it.

cd /usr/src/libgtest
sudo cmake .
sudo make
sudo cp libgtest.a /usr/local/lib

After installing libgtest, you can build the test suite and run it.

make test

C Example

// compile as: gcc -o example example.c -lbeanstalk

#include "beanstalk.h"
#include <stdio.h>
#include <assert.h>

int main() {
    BSJ *job;
    int id, socket = bs_connect("", 11300);

    assert(socket != BS_STATUS_FAIL);
    assert(bs_use(socket,    "test")    == BS_STATUS_OK);
    assert(bs_watch(socket,  "test")    == BS_STATUS_OK);
    assert(bs_ignore(socket, "default") == BS_STATUS_OK);

    id = bs_put(socket, 0, 0, 60, "hello world", 11);

    assert(id > 0);
    printf("put job id: %d\n", id);

    assert(bs_reserve_with_timeout(socket, 2, &job) == BS_STATUS_OK);

    printf("reserve job id: %d size: %lu\n", job->id, job->size);
    write(fileno(stderr), job->data, job->size);
    write(fileno(stderr), "\r\n", 2);

    printf("delete job id: %d\n", job->id);
    assert(bs_delete(socket, job->id) == BS_STATUS_OK);


C++ Example

// compile as: g++ -o example example.cc -lbeanstalk

#include "beanstalk.hpp"
#include <iostream>
#include <assert.h>

using namespace std;
using namespace Beanstalk;

int main() {
    Client client("", 11300);

    int id = client.put("hello");
    assert(id > 0);
    cout << "put job id: " << id << endl;

    Job job;
    assert(client.reserve(job) && job);
    assert(job.id() == id);

    cout << "reserved job id: "
         << job.id()
         << " with body {" << job.body() << "}"
         << endl;

    cout << "deleted job id: " << job.id() << endl;


  1. Fork / clone the repo.
  2. Make your changes.
  3. Make sure to add a test for any code changes.
  4. Make sure the tests pass.
  5. Send a pull request or a patch with explanation.