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

The Archive Base Latest Questions

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

I am using Java Tomcat as websocket server. I think the main difference between

  • 0

I am using Java Tomcat as websocket server.

I think the main difference between websocket and http streaming (I am not refering to polling and long polling) is websocket allows bi-directional communication which is similar to usual raw socket programming. (above is my understanding, could be wrong, feel free to correct me.)

My question is how the web client (browser) continue to send another request through the already-opened websocket? Usual http request will treat another request as new socket connection, but websocket does not, that is why I am confused, how it achieve that? It should be handled in Server side or Client (browser) side?

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

    Yes, websockets are bidirectional. An important consequence is that you may efficiently push data from the server to the client.

    Underlying sockets are just kept open (or reopened when needed if they couldn’t be kept open). Note that HTTP 1.1 yet did that :

    HTTP/1.1 is a revision of the original HTTP (HTTP/1.0). In HTTP/1.0 a
    separate connection to the same server is made for every resource
    request. HTTP/1.1 can reuse a connection multiple times to download
    images, scripts, stylesheets et cetera after the page has been
    delivered. HTTP/1.1 communications therefore experience less latency
    as the establishment of TCP connections presents considerable
    overhead.

    It must be handled both client-side and server-side. Of course that implies that both software be updated (old browsers and old servers can’t handle websockets).

    EDIT (following exchanges in comment) :

    Client side, here’s how a connection can be initialized :

    var ws = new WebSocket('ws://'+document.location.host+'/ws');
    ws.onopen = function() {
           // do something
    };
    ws.onerror = function() {
           // do something
    };
    ws.onclose = function() {
           // do something
    };
    ws.onmessage = function(msgevent) {
        var msg = JSON.parse(msgevent.data);
        // handle incoming message
    };
    

    You keep the ws variable, and after that you may push from client to server using the same connection with

    ws.send(window.JSON.stringify(msg)); // msg is a basic js object
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Tomcat server for my java based Application . My question is
When I run my java web application from eclipse using tomcat server, system gets
I am using Tomcat and Java (through Eclipse) and SQL Server 2008 R2 I
I am communicating to a Tomcat Server using a Java ME application on my
I am using Eclipse for Java EE and Tomcat Server 7.0. I created two
I'm using Eclipse Java EE IDE and launch Tomcat from the Server's tab on
i want to send request from android to java tomcat server using servlet, then
I'm attempting to build a JSF/Hibernate application using Java 7 and Tomcat 7. I
I am using Java 6 64-bit and STANDALONE Tomcat 6.0.18 on Vista 64-bit. I
We have an application running on Tomcat 6.0.32 and using JSSE (Java 1.6.0_26) for

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.