Udp timeout?


I want to timeout if I don’t get any messages.

The equivalent of that would be to simply do some sort of wait condition on the channel, and if there was no data ready then timeout.

I thought I had found something to do that in the docs, but now I can’t seem to find it, so if there is such a thing could someone point me to it ?

A couple of things about this code bother me.

One is that I’m putting bytes in the channel one at a time, and I’m thinking there’s a better way to do that.=

The other is that putting a close(sock) at the end of the code causes a core dump.

I’ve seen this mentioned in another post, and there didn’t seem to be any resolution.
Regardless of whether or not something’s being done incorrectly, a core dump on a mistaken close seems like a serious bug.


function getdata(address, chan)
    @async begin
         udpsock = UDPSocket()
         bind(udpsock, address, 2000)
         while true
             x = recv(udpsock)
             put!(chan, UInt8(length(x)))
             for byte in x
                 put!(chan, byte)

c = Channel{UInt8}(100)

getdata(ip"", c)

sock = UDPSocket()

for i=1:10
    println("i=", i)
    send(sock, ip"", 2000, "$i:Hello World from the UDP")
    n = take!(c)
    x = Array{UInt8,1}()
    for i=1:n
        push!(x, take!(c))


Based on methods(UDPSocket) and ?sock
sock = UDPSocket(sock.handle, 5 or 6?) for closing/closed UDP states ?