Click here to Skip to main content
11,637,415 members (59,459 online)
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 20: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 Sergey Alexandrovich Kryukov 304
1 OriginalGriff 295
2 stibee 288
3 270
4 himanshu agarwal 184
0 OriginalGriff 9,031
1 Sergey Alexandrovich Kryukov 8,643
2 Mika Wendelius 6,959
3 F-ES Sitecore 2,388
4 Suvendu Shekhar Giri 2,320

Advertise | Privacy | Mobile
Web04 | 2.8.150728.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