# UDP Multicast with Julia

**URL:** https://discourse.julialang.org/t/udp-multicast-with-julia/3045
**Category:** General Usage
**Tags:** question
**Created:** [April 4, 2017, 9:31am UTC](https://discourse.julialang.org/t/udp-multicast-with-julia/3045 "2017-04-04T09:31:41Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [April 4, 2017, 9:31am UTC](https://discourse.julialang.org/t/udp-multicast-with-julia/3045/1 "2017-04-04T09:31:41Z")

</div>

Hello,

I am using the following function to read UDP messages with Julia:

```julia
# background loop for receiving UDP messages, terminated with <ctrl> + <c>
function receiveData(server_ip)
	global terminate
	udpsock = UDPSocket()
	bind(udpsock, server_ip, port)
	i = 0
	try
		while true
			msg = String(copy(recv(udpsock)))
			enqueue!(q, msg)
		end
	catch my_exception
		if isa(my_exception, InterruptException)
			close(udpsock)
			terminate[1] = true
		end
	end
end

```

Now I want to receive multicast messages on the address 239.0.0.1. In C# this can be done by calling the method “JoinMulitcastGroup(adress)”. How can this be done in Julia?

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [April 4, 2017, 9:59am UTC](https://discourse.julialang.org/t/udp-multicast-with-julia/3045/2 "2017-04-04T09:59:50Z")

</div>

I tried to use the function setopt as documented here:  
[http://docs.julialang.org/en/stable/stdlib/io-network/](http://docs.julialang.org/en/stable/stdlib/io-network/)

but I am getting the error message:  
ERROR: UndefVarError: setopt not defined

Is there a possibility to call a C function of the Linux standard library directly  
to subscribe to a broadcast group?

---

<div class="post-metadata">

### Author: ![KajWiik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kajwiik/32/199_2.png) [@KajWiik](https://discourse.julialang.org/u/KajWiik)
#### Post date: [April 4, 2017, 11:14am UTC](https://discourse.julialang.org/t/udp-multicast-with-julia/3045/3 "2017-04-04T11:14:11Z")

</div>

Here is a nice example how to do it in C, maybe it is just stuffing the struct with correct values:

> <https://stackoverflow.com/questions/337422/how-to-udp-broadcast-with-c-in-linux/361876#361876>

In fact it is an offtopic reply → multicast.

I should work on broadcast and multicast in the near future so please report your findings 🙂.

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [April 6, 2017, 9:13pm UTC](https://discourse.julialang.org/t/udp-multicast-with-julia/3045/4 "2017-04-06T21:13:13Z")

</div>

Thanks for your hint!  
But this still seams to be unresolved. I created an issue:  
[https://github.com/JuliaLang/julia/issues/21300](https://github.com/JuliaLang/julia/issues/21300)

Uwe
