--- UDP BROADCAST / MULTICAST SENDER ---
489370
protected void send() {

		// Check number of packets
		int udpMaxDiscovery = transporter.getUdpMaxDiscovery();
		if (udpMaxDiscovery > 0) {
			if (numberOfSubmittedPackets >= udpMaxDiscovery) {

				// Has no timer
				if (timer != null) {
					logger.info("Discovery service stopped successfully, " + udpMaxDiscovery + " packets sent.");
					timer.cancel(false);
					timer = null;
				}

				// Has timer
				return;
			}
		}
		numberOfSubmittedPackets++;
		synchronized (receivers) {

			// First time use the all address to notify other nodes
			if (numberOfSubmittedPackets == 1) {
				for (UDPReceiver receiver : receivers) {
					receiver.send();
					try {
						Thread.sleep(200);
					} catch (InterruptedException interrupt) {
						return;
					}
				}
				return;
			}

			// Use the next network address
			nextIndex++;
			if (nextIndex >= receivers.size()) {
				nextIndex = 0;
			}
			receivers.get(nextIndex).send();
		}
	}
539220
@Override
  public void sendProbe(Probe probe) throws TransportException {

    LOGGER.info("Sending probe [" + probe.getProbeID() + "] on network inteface [" + networkInterface.getName() + "] at port [" + multicastAddress + ":" + multicastPort + "]");
    LOGGER.debug("Probe requesting TTL of [" + probe.getHopLimit() + "]");

    try {
      String msg = probe.asXML();

      LOGGER.debug("Probe payload (always XML): \n" + msg);

      byte[] msgBytes;
      msgBytes = msg.getBytes(StandardCharsets.UTF_8);

      // send discovery string
      InetAddress group = InetAddress.getByName(multicastAddress);
      DatagramPacket packet = new DatagramPacket(msgBytes, msgBytes.length, group, multicastPort);
      outboundSocket.setTimeToLive(probe.getHopLimit());
      outboundSocket.send(packet);

      LOGGER.debug("Probe sent on port [" + multicastAddress + ":" + multicastPort + "]");

    } catch (IOException e) {
      throw new TransportException("Unable to send probe. Issue sending UDP packets.", e);
    } catch (JAXBException e) {
      throw new TransportException("Unable to send probe because it could not be serialized to XML", e);
    }

  }
438252
@Override
	public Mono<Void> join(final InetAddress multicastAddress, NetworkInterface iface) {
		if (null == iface && null != datagramChannel.config().getNetworkInterface()) {
			iface = datagramChannel.config().getNetworkInterface();
		}

		final ChannelFuture future;
		if (null != iface) {
			future = datagramChannel.joinGroup(new InetSocketAddress(multicastAddress,
					datagramChannel.localAddress()
					               .getPort()), iface);
		}
		else {
			future = datagramChannel.joinGroup(multicastAddress);
		}

		return FutureMono.from(future)
		                 .doOnSuccess(v -> {
		                     if (log.isInfoEnabled()) {
		                         log.info(format(future.channel(), "JOIN {}"), multicastAddress);
		                     }
		                 });
	}
26937
public void sendBroadcast(CmsObject cms, String message, String sessionId) {

        sendBroadcast(cms, message, sessionId, false);

    }
914776
def broadcast(recipients)
      @node[FROM] = stream.user.jid.to_s
      recipients.each do |recipient|
        @node[TO] = recipient.user.jid.to_s
        recipient.write(@node)
      end
    end
147812
private static List<Future<List<DiscoveryIncomingMessage>>> sendDiscoveryRequests(DiscoveryOutgoingMessage pOutMsg,
                                                                                      int pTimeout,
                                                                                      LogHandler pLogHandler) throws SocketException, UnknownHostException {
        // Note for Ipv6 support: If there are two local addresses, one with IpV6 and one with IpV4 then two discovery request
        // should be sent, on each interface respectively. Currently, only IpV4 is supported.
        List<InetAddress> addresses = getMulticastAddresses();
        ExecutorService executor = Executors.newFixedThreadPool(addresses.size());
        final List<Future<List<DiscoveryIncomingMessage>>> futures = new ArrayList<Future<List<DiscoveryIncomingMessage>>>(addresses.size());
        for (InetAddress address : addresses) {
            // Discover UDP packet send to multicast address
            DatagramPacket out = pOutMsg.createDatagramPacket(InetAddress.getByName(JOLOKIA_MULTICAST_GROUP), JOLOKIA_MULTICAST_PORT);
            Callable<List<DiscoveryIncomingMessage>> findAgentsCallable = new FindAgentsCallable(address, out, pTimeout, pLogHandler);
            futures.add(executor.submit(findAgentsCallable));
        }
        executor.shutdownNow();
        return futures;
    }
1252942
@Override
	public void send(byte[] b, int off, int len) {
		handler.send(b, off, len);
	}
1015530
private ByteBuffer recv(int attempt)
          throws IOException, SocketException, SocketTimeoutException {
    int timeout = UDP_BASE_TIMEOUT_SECONDS * (int) Math.pow(2, attempt);
    logger.trace("Setting receive timeout to {}s for attempt {}...",
            timeout, attempt);
    this.socket.setSoTimeout(timeout * 1000);

    try {
      DatagramPacket p = new DatagramPacket(
              new byte[UDP_PACKET_LENGTH],
              UDP_PACKET_LENGTH);
      this.socket.receive(p);
      return ByteBuffer.wrap(p.getData(), 0, p.getLength());
    } catch (SocketTimeoutException ste) {
      throw ste;
    }
  }
89496
public void sendAuditEvent(AuditEventMessage[] msgs, InetAddress destination, int port) throws Exception 
	{
        if (!EventUtils.isEmptyOrNull(msgs)) {
    		// Check to validate port
    		int portToUse = getTransportPort(port);
        	
        	DatagramSocket socket = new DatagramSocket();

    		for (int i=0; i<msgs.length; i++) {
    			byte[] msgBytes = getTransportPayload(msgs[i]);
    			send(msgBytes, socket, destination, portToUse);
    		}
           socket.close();
        }
	}
36999
def _ipc_send(self, sock, message_type, payload):
        '''
        
        '''
        sock.sendall(self._pack(message_type, payload))
        data, msg_type = self._ipc_recv(sock)
        return data
897666
def send_data_on_udp(ip_address, port, data):
    """"""
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    try:
        sock.sendto(data.encode('utf-8'), (ip_address, port))
    except:
        LOGGER.exception('Failed to send trace to X-Ray Daemon')
    finally:
        sock.close()
897829
function sendMyInfo(senderMessage, senderInfo) {

        if (mode == "listen") {
            return;
        }

        var message = createMessage("ONE");
        var socket = dgram.createSocket({ type: 'udp4', reuseAddr: true });

        socket.bind(function() {
            socket.send(message, 0, message.length, senderMessage.port, senderInfo.address, function(err, bytes) {
                socket.close();
            });
        });

    }
1298389
public void send(String nodeID, byte[] packet) {
		if (nodeID == null) {
			logger.warn("Unable to send (missing nodeID)!");
			return;
		}
		if (packet == null || packet.length < 6) {
			logger.warn("Cannot send empty packet to node " + nodeID + "!");
			return;
		}
		SendBuffer buffer = null;
		try {

			// Get or create buffer
			boolean newBuffer = false;
			synchronized (buffers) {
				buffer = buffers.get(nodeID);
				if (buffer == null) {

					// Create new connection
					RemoteAddress address = transporter.getAddress(nodeID);
					if (address == null) {
						logger.warn("Unknown node ID (" + nodeID + ")!");
						return;
					}
					buffer = new SendBuffer(nodeID, address.host, address.port, debug);
					append(nodeID, buffer, packet);
					buffers.put(nodeID, buffer);
					newBuffer = true;
				} else {

					// Try to append to buffer
					if (!buffer.append(packet)) {

						// Buffer is closed
						RemoteAddress address = transporter.getAddress(nodeID);
						buffer = new SendBuffer(nodeID, address.host, address.port, debug);
						append(nodeID, buffer, packet);
						buffers.put(nodeID, buffer);
						newBuffer = true;
					}
				}
			}
			if (newBuffer) {

				// Close older connections
				if (maxConnections > 0) {
					cleanup();
				}

				// Add to opened buffers
				opened.add(buffer);

			} else if (buffer.key != null) {

				// Mark as writable
				buffer.key.interestOps(SelectionKey.OP_WRITE);
			}

			// Wake up selector
			if (selector != null) {
				selector.wakeup();
			}

		} catch (Throwable cause) {
			synchronized (buffers) {
				buffers.remove(nodeID);
			}
			LinkedList<byte[]> packets;
			if (buffer != null) {
				packets = buffer.getUnsentPackets();
			} else {
				packets = new LinkedList<>();
			}
			if (packets.isEmpty() && packet != null) {
				packets.addLast(packet);
			}
			transporter.unableToSend(nodeID, packets, cause);
		}
	}
840752
private void setUpTransmitter(String params) throws IOException {
        log.info("Starting UDP transmitter for: " + params);
        if (!params.contains(DVOETOCHIE)) {
            throw new IllegalArgumentException("Wrong syntax for udp-transmitter command: " + params);
        }
        String transmitToAddr = params.substring(0, params.indexOf(DVOETOCHIE)).trim();
        params = params.substring(params.indexOf(DVOETOCHIE) + 1).trim();

        if (!params.contains(DVOETOCHIE)) {
            throw new IllegalArgumentException("Wrong syntax for udp-transmitter command: " + params);
        }
        int transmitToPort = Integer.parseInt(params.substring(0, params.indexOf(DVOETOCHIE)).trim());
        params = params.substring(params.indexOf(DVOETOCHIE) + 1).trim();

        setUpMetrics(params.split(TAB));
        DatagramChannel transmitter = DatagramChannel.open();
        SocketAddress addr = new InetSocketAddress(transmitToAddr, transmitToPort);
        transmitter.connect(addr);
        transmitter.configureBlocking(false);
        controller.registerWritingChannel(transmitter, this);
        controller.connectUDPClient(addr, transmitter, this);
    }
81639
protected void processReceivedMessage(DatagramPacket packet, byte[] buffer) {

		String received = new String(buffer).trim();
		String tokens[] = received.split("\\|");
		if (tokens.length != 3) {
			logger.warn("Malformed UDP message received (" + received + ")!");
			return;
		}

		// Check prefix and nodeID
		if (!namespace.equals(tokens[0]) || nodeID.equals(tokens[1])) {
			return;
		}
		if (tokens[1].isEmpty()) {
			logger.warn("Empty nodeID received!");
			return;
		}

		// Get source hostname or IP
		String host;
		try {
			InetAddress address = packet.getAddress();
			if (useHostname) {
				host = address.getHostName();
				if (host == null || host.isEmpty() || host.contains("localhost")) {
					host = address.getHostAddress();
				}
			} else {
				host = address.getHostAddress();
				if (host == null || host.isEmpty() || host.startsWith("127.")) {
					host = address.getHostName();
				}
			}
			if (host == null || host.isEmpty()) {
				logger.warn("Unable to detect sender's hostname!");
				return;
			}
		} catch (Exception cause) {
			logger.warn("Unable to detect sender's IP address or hostname!", cause);
			return;
		}
		int port = 0;
		try {
			port = Integer.parseInt(tokens[2]);
			if (port < 1) {
				logger.warn("Invalid port number (" + port + ")!");
				return;
			}
		} catch (Exception cause) {
			logger.warn("Invalid port number format (" + tokens[2] + ")!");
			return;
		}

		// Notify TCP Transporter
		transporter.udpPacketReceived(tokens[1], host.toLowerCase(), port);
	}
877876
@Override
    protected void sendMessage(INDArray message, int iterationNumber, int epochNumber) {
        // here we'll send our stuff to other executores over the wire
        // and let's pray for udp broadcast availability

        // Send this message away
        // FIXME: do something with unsafe duplication, which is bad and used ONLY for local spark
        try (MemoryWorkspace wsO = Nd4j.getMemoryManager().scopeOutOfWorkspaces()) {
            long updateId = updatesCounter.getAndIncrement();

            VoidParameterServer.getInstance().execDistributedImmediately(
                            new SilentUpdatesMessage(message.unsafeDuplication(), updateId));
        }


        // heere we update local queue
        super.sendMessage(message, iterationNumber, epochNumber);
    }
1224205
void broadcast(Iterator<String> peers, Message message) {
    transport.broadcast(peers, message);
  }