Károly Neue
Károly Neue

Reputation: 99

Websokcet use asynchronous communication?

I must write a JAVA standalone websocket client. I know that webscoket is a duplex communication protocol, but I don't know how does it exactly work. This communication is asynchronus? (like a JMS queue)

Upvotes: 0

Views: 287

Answers (1)

tyg
tyg

Reputation: 14966

Since Websockets use an underlying TCP-Connection, all communication should be done asynchronously. This is, however, an implementation detail of your code. If you want to block your code to wait for a reply, that's up to you (though not recommended).

Websockets for Java were specified in JSR 356, so you can use them out-of-the-box in your application server. If you don't have an application server, you can use a standalone implementation like Tyrus instead.

See javax.websocket client simple example for some code samples.

Upvotes: 1

Related Questions