Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No recvfrom in socket.jl #8901

Closed
jech opened this issue Nov 4, 2014 · 6 comments · Fixed by #9418
Closed

No recvfrom in socket.jl #8901

jech opened this issue Nov 4, 2014 · 6 comments · Fixed by #9418

Comments

@jech
Copy link

jech commented Nov 4, 2014

It looks like there's no binding to recvfrom in the socket library, which makes it impossible to write UDP servers.

@ihnorton
Copy link
Member

@jech there is no binding to recvfrom because all networking is done via libuv's UDP API. Here is a minimal server example:

@async begin
           s = UDPSocket()
           bind(s, ip"0.0.0.0", 10000)
           while true
               b = recv(s)
               print(bytestring(b))
           end
       end

(tested with echo "hello" | nc -4u -w0 127.0.0.1 10000)

@ihnorton
Copy link
Member

Small clarification: on 0.3, use UdpSocket instead (note lowercase).

@ihnorton
Copy link
Member

Documentation added in 1d8e162. Closing for now but if something is missing, leave a comment and we'll reopen.

@jech
Copy link
Author

jech commented Dec 16, 2014

I must be missing something.

In order to write a UDP server, you need to know the address from which the packet was sent in order to send a reply. That's usually done with recvfrom.

How do you send a reply back to the client in Julia?

@ihnorton
Copy link
Member

You are not missing anything - I was being dense, so thanks for explaining.

The source address is provided in the callback from libuv (see _uv_hook_recv in socket.jl and the on_read example in the libuv UDP section). We currently don't do anything with the address, but I will implement and propose an update.

@racinmat
Copy link

racinmat commented Aug 8, 2020

Hi, is there any way to send a reply back to the client in Julia?
I can't find anything for Julia 1.5.
The recvfrom is implemented, but you can't use that if the client does not have public IP, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants