maqbool

maqbool

Getting the error {:error, :eacces} while trying to connect to an udp server on port 123

I was trying to connect to a NTP server using :gen_udp module but it seems anything below port 1000 is getting an error{:error, :eacces}

I am not sure why is that a case

Most Liked

Ankhers

Ankhers

That python code does not specify the port to open on the client. If it did, there would have been a third argument to socket.socket. Leaving out the third argument, which is the port number on the client, is the equivalent to passing 0 as the port to :gen_udp.open.

NobbZ

NobbZ

Only root is allowed to bind to ports less than 1024.

voltone

voltone

The port parameter in :gen_udp.open/1 is the local port on which the application receives datagrams. If you’re implementing a client you don’t need to bind to port 123, you can just let the OS pick an available (unprivileged) port: :gen_udp.open(0).

When you send datagrams to the server, using :gen_udp.send/4, you set the destination port to 123. You don’t need special permissions for that.

NobbZ

NobbZ

:gen_udp.open/1/2 opens the port to send and receive. If you just want to send datagrams without receiving, then using 0 as port is usually sufficient. Also remember, that open takes your local port, while the remote port is an argument to send/4. Both ports may be (and in fact almost ever are) different.

I do not know though, how pythons UDP implementation works.

Where Next?

Popular in Questions Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
Exadra37
Sometimes I want to check if the input into a function is not a blank string. My first approach: defmodule Example do def do_stuff(s...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New

Other popular topics Top

pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New

We're in Beta

About us Mission Statement