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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:27:02+00:00 2026-06-11T19:27:02+00:00

How do I create a TCP socket in Java? How do I create such

  • 0

How do I create a TCP socket in Java?

How do I create such a TCP connection that it terminates only when I tell it to otherwise it remains open?

How do I use keepalives to know whether the server or client is still available?

Please Help!

  • 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-06-11T19:27:04+00:00Added an answer on June 11, 2026 at 7:27 pm

    How do I create a TCP socket in Java?

    Socket socket = new Socket(hostname, port);
    

    http://docs.oracle.com/javase/tutorial/networking/sockets/index.html

    How do I create such a TCP connection that it terminates only when I tell it to otherwise it remains open?

    They will remain open until either you or the other end closes it.

    How do I use keepalives to know whether the server or client is still available?

    That is up to you. You can send different messages, one of which is a heartbeat which tells the other end you are alive.

    A common thing to do if you are sending binary messages is to send the length as an unsigned short or int value. I use a message of “length” 0 as a heartbeat.

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

Sidebar

Related Questions

I want to create a TCP socket that listens only on a specific interface
I need to use the tcp socket connection to get the data from a
When I create a TCP socket in blocking mode and use the send (or
I try to create a tcp/ip socket connection from a c# app to a
I want to create a C++ server/client that maximizes the throughput over TCP socket
I'm writing a Java program that establishes a TCP connection with a mail server
How to create a TCP socket using Objective-C, check if some TCP ports are
If you create a TCP client socket with port 0 instead of a non-zero
I am trying to create a new TCP socket in Android emulator. Below is
Assume that i have created a client TCP Socket in Activity A. I want

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.