-1

I just wondering if someone can explain me the difference\destination of Jetty WebSockets and Java Sockets.

What I've read:

Jetty WebSockets:

  1. Fast data exchange for applications with intensive communication
  2. Cross-domain application
  3. Complex applications with multiple asynchronous blocks on a page
  4. Applications adhere to standards
  5. "Long-playing" applications

Question1: Can you explain me 3rd, 4th and 5th statements please?

Java Sockets:

  1. Non-synchronous data exchange

Question2: What attractive possibilities provides Java Sockets which makes them so widely used?

Difference between Java Sockets & Jetty WebSockets:

I've read this post, but still can't understand it.

yes, they are really different. WebSockets typically run from browsers connecting to Application Server over a protocol similar to HTTP that runs over TCP/IP. So they are primarily for Web Applications that require a permanent connection to its server. On the other hand, plain sockets are more powerful and generic. They run over TCP/IP but they are not restricted to browsers or HTTP protocol. They could be used to implement any kind of communication.

Question3: Can you explain me what do they mean by "powerful and generic"? Example please?

Question4: How to decide what to use Java Sockets or Jetty WebSockets?

Community
  • 1
  • 1
VB_
  • 45,112
  • 42
  • 145
  • 293
  • WebSockets can be built on top of regular sockets. – Johm Don Apr 24 '14 at 20:55
  • @JohmDon than why someone may decide to use Java Sockets? I used Jetty WebSockets and find no reasons to switch to Java Sockets. – VB_ Apr 24 '14 at 20:56
  • 1
    It entirely depends on what you use them for. – Johm Don Apr 24 '14 at 21:00
  • @JohmDon surely. But the question is that I can't imagine the situation when Java Sockets will be better. – VB_ Apr 24 '14 at 21:01
  • Think of direct Java App to App communication (or even to non-java). Sockets do the job there and you can run any protocol you can think of on top of TCP or UDP. – Fildor Apr 24 '14 at 21:05
  • @Fildor may you provide example please? I mean the example when Java Sockets solve the problem better than WebSockets. I've never use another protocols.. – VB_ Apr 24 '14 at 21:08
  • If you want a Client to send 0x01 and expect the server to answer with "0x00". You just open a socket and send those bytes. No need to wrap them in HTTP ... pretty stupid example but you might get the concept. – Fildor Apr 24 '14 at 21:10
  • @Fildor very small performance benefit. Where it is possible in real applications? – VB_ Apr 24 '14 at 21:11
  • For one transaction, yes. Make that some gazillion ones ... You can (you don't have to) reduce overhead if the application allows for it. And not talking about performance only. I had an application talking to an ATM interface over Socket. There just wasn't an HTTP-API, only a byte-protocol. – Fildor Apr 24 '14 at 21:14

1 Answers1

2

A strange question.

  1. Jetty Web sockets implement the Web Socket protocol.
  2. Java sockets implement the TCP and UDP protocols.
  3. Web sockets are built on TCP sockets.
  4. Web sockets provide a single heavyweight protocol for communication between clients and application servers.
  5. TCP sockets provide a lightweight protocol, over which you can implement things like Web sockets, RMI, HTTP, FTP, SMTP, POP, LDAP, SSL, SSH, LANs, NNTP, RDP, CORBA, J2EE, Telnet, ...

You're comparing chalk and cheese, or apples and oranges. Java sockets are an essential component. Web sockets are a special-purpose component. There's no sense in asking which is better, or whether you can throw one of them away.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • @EJB but do all those protocols haven't got specific sockets implementations? I mean like WebSockets for http. And for what is that generty? How offten do we need to switch the communication protocol in real application? – VB_ Apr 25 '14 at 14:11
  • and one more question: what is the specific of HTTP protocol, that for all another protocols we can use Java Sockets but for HTTP we must use specific realization? – VB_ Apr 27 '14 at 06:32
  • VolodymyrBakhmatiuk More strange questions. 1. I don't understand the grammar of this question. 2. I don't understand the word 'generty' in this question. 3. I don't understand the relevance of this question. 4. I don't accept the premiss of this question: Java has SSLSockets for example, and higher-level I/O abstractions for FTP, HTTP, ... (4) doesn't seem like 'one more' question, but a slightly less incomprehensible version of the first. – user207421 May 22 '17 at 18:10