Skip to content

Multiple binds on DGRAM socket #4434

@sphaero

Description

@sphaero

Issue description

Multiple binds on a DGRAM socket only work for the first bind

Environment

  • libzmq version: master ( 875c2b1)
  • OS: Debian testing

Minimal test code / Steps to reproduce the issue

#include "zmq.h"
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>

int main (void)
{
  void *context = zmq_ctx_new ();
  void *data_socket = zmq_socket (context, ZMQ_DGRAM);

  int rc = zmq_bind(data_socket, "udp://*:1511");
  assert(rc != -1);
  if (rc == -1)
  {
      printf ("E: bind failed: %s\n", strerror (errno));
      return 1;
  }

  rc = zmq_bind(data_socket, "udp://*:6200");
  if (rc == -1)
  {
      printf ("E: bind failed: %s\n", strerror (errno));
      return 1;
  }
  assert (rc == 0);

  int count = 0;
  printf("starting recv\n");
  while (count < 10) {
    char buffer [100];
    rc = zmq_recv (data_socket, buffer, 100, 0);
    assert(rc > 0);
    printf ("Received Hello %.*s\n", 100, buffer);
    count++;
  }

What's the actual result? (include assertion message & call stack if applicable)

There's no error. Just that no data is being received on port 6200

What's the expected result?

Both ports would receive data

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions