M
M
Maxim Ivanov2016-10-07 12:44:46
Java
Maxim Ivanov, 2016-10-07 12:44:46

How to write a simple web socket in java?

In principle, I understand what sockets are at the theoretical level
. But how can I implement them?

I installed spring, the hello world application starts up,
now I'm wondering, according to what scheme

I can write code so that
one method listens to the address endlessly and receives any messages,
the other method sends them,

that is, should I put a local server somewhere?

$ static 
serving "." at http://127.0.0.1:8080


and how can my code listen to this particular address and port, or do I still not really understand the meaning?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rou1997, 2016-10-07
@Rou1997

and how can my code listen to exactly this address and port

From the server side, you yourself will set which address and port to listen to, and from the client side you will connect to this address and port.
What do you have in mind?
In general, the framework is redundant for this task, two console applications would be enough, one "server" and the other "client".
one method endlessly listened to the address and received any messages
another method sent them
And both are in Spring i.e. server side? What's the point? Then one is needed in Spring ("server"), but the other in the browser, that is, in JS, Flash, or a Java applet ("client").

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question