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

  • Home
  • SEARCH
  • 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 6945467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:26:23+00:00 2026-05-27T13:26:23+00:00

I am working on a project that. It will connect to a remote host

  • 0

I am working on a project that. It will connect to a remote host using tcp sockets from a service. And interact with it for getting and sending data.

The flow, I have planned is;

a singleton socket class. Which returns a connected socket refference;

an activity to ask user for remote server’s ip and port.
a service triggered(intent) by the activity with the parameters of ip:port.
service will get the socket using singleton socket class.
and then service will read a data; parse it and show user for user actions in a new action window ( intended).
after user completed the action; result will be sent to the server. and new request will be read.

problem/query is here;

  • when you come back to the service for second data read operation; will the socket be there ? (or garbage collected )
    because after data read operation started no new connection accepted.

  • will the first service die after calling the user actions activity ?

  • what happens if I call the service using startService from an activity, a new service created or the existing before started service called back again ?

  • how can I let the service live for ever unless I said it to die.

Sorry, If I am asking silly questions.

  • 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-27T13:26:23+00:00Added an answer on May 27, 2026 at 1:26 pm

    Here’s how I see it:

    when you come back to the service for second data read operation; will
    the socket be there ? (or garbage collected ) because after data read
    operation started no new connection accepted.

    If the object is static and has the socket as a member variable it will most likely be there, you should have safeguards in your single pattern to shield from this problem (if single==null){...}, you could also try managing it by overriding the Application class and adding a factory method in there. You need to make sure the socket is open and closed correctly and not just left hanging as this could create problems

    EDIT:

    Whether the actual socket is still open will depend on the timeout of the socket

    will the first service die after calling the user actions activity ?

    Services need to be told to stop and so it will not die

    what happens if I call the service using startService from an
    activity, a new service created or the existing before started service
    called back again ?

    If the service is running, the it will not create another, it will call the onStartCommand() of the running service

    how can I let the service live for ever unless I said it to die.

    This is default behavior

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

Sidebar

Related Questions

I´m working on a project that basically will show some data collected from hardware
I'm working on a java project that receives midi events from midi hardware using
I'm working on a project that will be distributed with GNU autoconf/automake, and I
I am working on a project that will require internationalisation support down the track.
I'm working on a project that will require me to implement a calendar. I'm
I'm working on a project that will require me to take various .vbproj and
I'm working on a project that will have a single table holding lots and
I am currently working on a project that will store specific financial information about
I am going to be working on a project that will heavily involve indexing
I'm working on a web project that will (hopefully) be available in several languages

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.