Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
Hi ,
Im new to html5 websocket , is that possible to establish a connection from websocket to java socket. if it is possible how it can be done .

Kindly help me out.
Thanks in advace.
Posted 31-Mar-13 21:37pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Exact similar discussion here, marked solved: Can you connect an HTML5 web socket to a Java Socket?[^].
...WebSocket works by the client side opening a port 80 connect to the server side, and sending a variant HTTP 1.1 request to the server to negotiate a WebSocket connection. If the server recognizes this, it will send a suitable response, and then allow the still open TCP connection to be used for full-duplex client-server interactions.
It looks like it would be possible to quickly put together a server-side that just understood WebSocket negotation and not full HTTP. However, I think you are better off looking at existing WebSocket implementations, including those embedded in HTTP servers / protocol stacks.
This Wikipedia page compares a number of WebSocket implementations, and should help you in deciding which server-side implementation to use.
But to directly answer your literal question, a WebSocket client can only connect to a WebSocket-aware server; i.e. that one that can perform the initial negotiation.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 475
1 OriginalGriff 425
2 Sascha Lefévre 289
3 CPallini 285
4 CHill60 260
0 Sergey Alexandrovich Kryukov 9,773
1 OriginalGriff 9,290
2 Peter Leow 5,137
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 3,036

Advertise | Privacy | Mobile
Web04 | 2.8.150327.1 | Last Updated 1 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100