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 6011811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:18:48+00:00 2026-05-23T02:18:48+00:00

I have recently nose dived into socket programming using java, and I have a

  • 0

I have recently nose dived into socket programming using java, and I have a few general sort of questions.

There is a bind() method, as well as a connect() and disconnect(). There is no unbind(). Is this because upon disconnecting the socket is unbound? Does garbage collection take care of this once the program exits? Or is this not even a valid question?

Also, upon creating a DatagramSocket, how is it different if I only provide the port and the address? I am creating a program to collect data off a network, as the data floats around and log it. Should I just use the local address? Could not using the address when I create the socket cause me to not be able to collect packets?

I am just trying to get a stronger understanding on the inner-workings of these things.

  • 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-23T02:18:49+00:00Added an answer on May 23, 2026 at 2:18 am

    There are about 15 independent questions in there, but I’ll do my best to address them:

    There is a bind() method, as well as a connect() and disconnect(). There is no unbind(). Is this because upon disconnecting the socket is unbound?

    bind() is separate from connect() and disconnect(). Bind is used to bind a socket to a particular port — effectively to “listen” for connections whereas connect() is used to open a connection to a socket that is already listening on a particular port. The equivalent of unbind() is close()

    Does garbage collection take care of this once the program exits? Or is this not even a valid question?

    This is a totally valid question, although garbage collection is a technology used for memory management, not socket/OS resource management. If you don’t release a particular port, it will remain associated with your application until your application terminates and it will then be reclaimed by the OS. This is OS-level functionality, not JVM functionality, etc.

    Also, upon creating a DatagramSocket, how is it different if I only provide the port or provide the port and the address?

    At some point, you have to provide the internet address and port or the socket you wish to connect to or to bind to. There’s no way around it.

    I am creating a program to collect data off a network, as the data floats around and log it. Should I just use the local address? Could not using the address when I create the socket cause me to not be able to collect packets?

    I’m not sure what you’re asking here, are you talking about logging all packets on the network, aka a sniffer? That’s going to require more than simple datagram programming. You actually have to inject yourself at the network-adapter level to intercept packets as they are read off the line. What you’re talking about will only allow you to receive packets that are sent to the specific port you’re listening to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently converted my IPad application into a Universal Application. I am re-using
I have recently started looking into MQs and I had some very basic questions,
I have recently started using Vim as my text editor and am currently working
I have recently been doing a bit of investigation into the different types of
I have recently run across these terms few times but I am quite confused
I have recently tried to write an application in c# using EWS to read
I have recently started using SQLALCHEMY to query a my-sql database. I want to
have recently changed the url structure of my website and have added a few
I have recently come across a very simple Typed DataTable (without using a .XSD)(I've
I have recently been running into many different areas of SQL Server that I

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.