Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5977283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:20:54+00:00 2026-05-22T21:20:54+00:00

I write one module, which has one loop function, the function will send udp

  • 0

I write one module, which has one loop function, the function will send udp packet forever. i debug the program in erlang console, I want to know how to close the UDP socket ?
or else erlang will always print the debug message in console. thanks!

start() ->
  {ok, Sock} = gen_udp:open(0, []),
  send(Sock).

send(Sock) ->
  gen_udp:send(Sock, "127.0.0.1", 3211, "hello world"),
  timer:sleep(5000),
  send(Sock). 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:20:55+00:00Added an answer on May 22, 2026 at 9:20 pm

    There are two things to be considered here

    1. If the process is the owner of
      the socket.In that case you can
      directly use gen_udp:close(Sock).
    2. If the process is not the owner of the socket then use
      gen_udp:controlling_process(Sock,Pid)
      where Pid is the process id of the
      new owner of the socket. Now you can
      use gen_udp:close(Sock) from this
      process. http://www.erlang.org/doc/man/gen_udp.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Newbie here...can I write one program which incorporates .NET LINQ and also various Java
When you write a program in c which has a lot of printf for
Do you write one test per function/method, with multiple checks in the test, or
How does one write a unit test that fails only if a function doesn't
I am attempting to write a one-line Perl script that will toggle a line
I'm on Delphi 2009, and my application contains a data module, which has a
I was searching searching for a pure python module which has functionality equalent to
Mac OS X has an application called defaults which allows one to set and
I want to write a program which would download all post offices given a
How can I write 'one bit' into a file stream or file structure each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.