{"action":"created","issue":{"url":"https://api.github.com/repos/zeromq/libzmq/issues/1638","labels_url":"https://api.github.com/repos/zeromq/libzmq/issues/1638/labels{/name}","comments_url":"https://api.github.com/repos/zeromq/libzmq/issues/1638/comments","events_url":"https://api.github.com/repos/zeromq/libzmq/issues/1638/events","html_url":"https://github.com/zeromq/libzmq/pull/1638","id":115750364,"number":1638,"title":"Tcp buffer options to set RECV/SEND buffer","user":{"login":"jens-auer","id":9391718,"avatar_url":"https://avatars.githubusercontent.com/u/9391718?v=3","gravatar_id":"","url":"https://api.github.com/users/jens-auer","html_url":"https://github.com/jens-auer","followers_url":"https://api.github.com/users/jens-auer/followers","following_url":"https://api.github.com/users/jens-auer/following{/other_user}","gists_url":"https://api.github.com/users/jens-auer/gists{/gist_id}","starred_url":"https://api.github.com/users/jens-auer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jens-auer/subscriptions","organizations_url":"https://api.github.com/users/jens-auer/orgs","repos_url":"https://api.github.com/users/jens-auer/repos","events_url":"https://api.github.com/users/jens-auer/events{/privacy}","received_events_url":"https://api.github.com/users/jens-auer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-08T18:22:31Z","updated_at":"2015-11-12T22:16:53Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/zeromq/libzmq/pulls/1638","html_url":"https://github.com/zeromq/libzmq/pull/1638","diff_url":"https://github.com/zeromq/libzmq/pull/1638.diff","patch_url":"https://github.com/zeromq/libzmq/pull/1638.patch"},"body":"I've added two new socket options to set the receive/send buffer for TCP sockets. This could be useful to specify a different buffer size from applications to reduce overhead from syscalls, e.g. when sending many large messages."},"comment":{"url":"https://api.github.com/repos/zeromq/libzmq/issues/comments/156253334","html_url":"https://github.com/zeromq/libzmq/pull/1638#issuecomment-156253334","issue_url":"https://api.github.com/repos/zeromq/libzmq/issues/1638","id":156253334,"user":{"login":"c-rack","id":169184,"avatar_url":"https://avatars.githubusercontent.com/u/169184?v=3","gravatar_id":"","url":"https://api.github.com/users/c-rack","html_url":"https://github.com/c-rack","followers_url":"https://api.github.com/users/c-rack/followers","following_url":"https://api.github.com/users/c-rack/following{/other_user}","gists_url":"https://api.github.com/users/c-rack/gists{/gist_id}","starred_url":"https://api.github.com/users/c-rack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c-rack/subscriptions","organizations_url":"https://api.github.com/users/c-rack/orgs","repos_url":"https://api.github.com/users/c-rack/repos","events_url":"https://api.github.com/users/c-rack/events{/privacy}","received_events_url":"https://api.github.com/users/c-rack/received_events","type":"User","site_admin":false},"created_at":"2015-11-12T22:16:53Z","updated_at":"2015-11-12T22:16:53Z","body":"Hi Jens,\r\n\r\nthanks for the feedback! I might have missed that conversation on the ML and while I really respect Pieter's opinion, I disagree that using the real number of bytes isn't a good idea.\r\n\r\nSo I tried the following test code:\r\n```c\r\nvoid test_setsockopt()\r\n{\r\n    int rc;\r\n    void *ctx = zmq_ctx_new();\r\n\r\n    void *socket = zmq_socket(ctx, ZMQ_PUSH);\r\n\r\n    int val = 0;\r\n    size_t placeholder = sizeof(val);\r\n\r\n    rc = zmq_getsockopt(socket, ZMQ_TCP_RECV_BUFFER, &val, &placeholder);\r\n    assert(rc == 0);\r\n    printf(\"val: %d\\n\", val);\r\n    assert(val == 3);\r\n    \r\n    rc = zmq_setsockopt(socket, ZMQ_TCP_RECV_BUFFER, &val, sizeof(val));\r\n    assert(rc == 0);\r\n    printf(\"val: %d\\n\", val);\r\n    assert(val == 3);\r\n\r\n    rc = zmq_getsockopt(socket, ZMQ_TCP_RECV_BUFFER, &val, &placeholder);\r\n    assert(rc == 0);\r\n    printf(\"val: %d\\n\", val);\r\n    assert(val == 3);\r\n    \r\n    val = 10;\r\n    \r\n    rc = zmq_setsockopt(socket, ZMQ_TCP_RECV_BUFFER, &val, sizeof(val));\r\n    assert(rc == 0);\r\n    printf(\"val: %d\\n\", val);\r\n    assert(val == 10);\r\n\r\n    rc = zmq_getsockopt(socket, ZMQ_TCP_RECV_BUFFER, &val, &placeholder);\r\n    assert(rc == 0);\r\n    printf(\"val: %d\\n\", val);\r\n    assert(val == 10);\r\n    \r\n    zmq_close(socket);\r\n    zmq_ctx_term(ctx);\r\n}\r\n```\r\n\r\nand it failed with:\r\n\r\n```\r\nFAIL: tests/test_sockopt\r\n==============================\r\nAssertion failed: (val == 3), function test_sockopt, file tests/test_sockopt.cpp, line 29.\r\nval: 3\r\nval: 3\r\nval: 8192\r\nFAIL tests/test_socketopt (exit status: 134)\r\n```\r\n\r\nSo setting the buffer size to 3 and getting it back (8192) return different results.\r\n\r\nAlso, there is a `return 0;` missing in `zmq::options_t::setsockopt`, so setting the new options will always return a result code of -1 instead of 0.\r\n\r\nAnyway, I like your contribution to make the recv/send buffers configurable. So I'll merge your PR and we will address the adjustments/fixes in other PRs."}}