This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Sxw's profile picture

Websockets!

Started by Sxw, 26 February 2013 - 03:49 PM
Sxw #1
Posted 26 February 2013 - 04:49 PM
I was wondering, I don't think this has been suggested before, that you could add Websockets. They are kinda like sockets, except they are primarily used in javascript. There's allready a java library under the MIT Lisence, so it has been done in java(https://github.com/TooTallNate/Java-WebSocket) I would love this. :P/> So long and thanks for all the fish.
immibis #2
Posted 26 February 2013 - 04:52 PM
ComputerCraft doesn't use JavaScript.

Also sockets have already been denied.
Sxw #3
Posted 26 February 2013 - 05:12 PM
They may have, but Websockets are way different, and they are only primarily used in javascript to communicate with the server. I know that java has nothing to to with javascript(ECMAScript)
immibis #4
Posted 26 February 2013 - 07:16 PM
They may have, but Websockets are way different, and they are only primarily used in javascript to communicate with the server. I know that java has nothing to to with javascript(ECMAScript)
Then what would it communicate with in CC?
Dlcruz129 #5
Posted 27 February 2013 - 04:16 AM
Isn't there a ccSockets peripheral?

(Too lazy to search and link)
Pharap #6
Posted 09 March 2013 - 01:55 PM
Can you give a better explanation for what web sockets do and what their use would be?
Dlcruz129 #7
Posted 09 March 2013 - 03:48 PM
Can you give a better explanation for what web sockets do and what their use would be?

http://en.wikipedia.org/wiki/Web_socket
Pharap #8
Posted 09 March 2013 - 04:07 PM
Can you give a better explanation for what web sockets do and what their use would be?

http://en.wikipedia....wiki/Web_socket

I asked if you could give one, not if you could link me to one (that's lazy).
If you want the suggestion to be considered properly, at least give an explanation of how it would work and what good it would serve, otherwise people are unlikely to back or even consider backing your idea.
sophiamaster #9
Posted 13 March 2013 - 03:12 PM
I can give an example. I've been working on this project of mine on this server my friend and I own. It is simular to rednet and uses the modem on a repeater tower network that does nifty little things like dynamic dhannel allocation for emulation of virtual circuit switching, etc- anyhow, my idea was to allow this to carry (with authentication in mind) through a proxy server application that would be used to link servers together. I could use kilos Socket library for this. But I do not want to require anyone to install an extra periphreal, I just wanted to use de facto supplied hardware. HTTP was available, unfortunately I would have to coroutine two HTTP connections, one which polls for new data from the remote side and one which sends requests, where a websocket would be very handy. The whole benefit of having websockets is generally that CC computers will have easy access to websocket enabled web applications. Because I'm a Perl programmer, I could have used a simple lightweight CGI framework to build a websocket application with little ease.

So while kilo's socket library is available, websockets would be a neat benefit for some more advanced HTTP related communication, and could be part of the HTTP API instead of making a new one, as well as not requiring additional installation of extra periphreals.
Pharap #10
Posted 13 March 2013 - 03:52 PM
I like the idea of linking servers. If it can allow two separate MC servers to connect via a non MC server (like a server written in php designed to handle such requests) then I'm all for it. If that can work, then a 'CC Internet Network' isn't out of the question (like pastebin, but more standardised and local to CC users, plus with extra functionality). If that's possible, it can only mean the growth of an already well built programming community.

Plus I highly advocate the use of Perl, Larry is a crazy crazy man lol
sophiamaster #11
Posted 13 March 2013 - 04:06 PM
Yeah. My idea was to make that decentralized, keep divisions seperate, but connectable (the first two digits of a number, the international code), then have an area code which is the proxy node to connect to, a city code (for your town or towns, etc), and the local number or node to connect to. something simple, and just let these proxy nodes assign area codes like DHCP requests. It wouldn't require anyone to know a large ammount of networking to implement, in fact, because it's decentralized, you dont have to run your php or perl or whatever node, you can connect to someone elses if you have a username / password to get on with, and it just makes communicating fun. But I just recently realized it's going to be a pain in the butt for me to implement if I don't use kilo's socket library or if websockets or such aren't implemented. So that's why I back the websockets idea.
Pharap #12
Posted 13 March 2013 - 04:19 PM
It's enough to tempt me into finally getting around to learning web stuff *is primarily an in-spare-time game programmer and general application programmer*. I haven't bothered to learn any of the protocols properly or any connnect-y stuff besides making an automatic updater for a game that read repos from dropbox and updated the corresponding files. This on the other hand makes me feel like I should learn this stuff so I can put support for it in a later release of my OS (if it gets off the ground).
Dlcruz129 #13
Posted 13 March 2013 - 05:07 PM
I wanted to make a program to connect to the computercraft IRC, but without web sockets it would be too much work. I support this idea.
immibis #14
Posted 13 March 2013 - 07:45 PM
Could someone give a better explanation for what web sockets would do in CC differently from normal sockets?
sophiamaster #15
Posted 14 March 2013 - 02:24 AM
Honestly, there is not a whole lot of difference. The benefit of web sockets in CC is that it uses the HTTP protocol, therefore uses HTTP headers, and could be part of the HTTP API, and with possibly a small ammount of changes, the web sockets api calls can be written mostly with the HTTP API if the HTTP API allows the custom construction of HTTP headers. For those who want to build websockets with kilo's socket library, one would have to also re-implement the HTTP protocol just to make the socket handshake a new connection, which means that connecting to web applications that make use of websockets with the HTTP API is that much harder.
Dlcruz129 #16
Posted 14 March 2013 - 03:10 AM
Could someone give a better explanation for what web sockets would do in CC differently from normal sockets?

I think they would just be able to connect a socket to a website. Did you think they would be rednet sockets?
sophiamaster #17
Posted 14 March 2013 - 03:50 AM
Did you think they would be rednet sockets?

I hope not. The problem is that rednet is higher level than using the modem directly. making it a rednet socket would make any other form of networking that needed to use web sockets pretty much useless without encapsulating into rednet which in some situations is not an ideal solution for modem communication. You'd want it to be part of the HTTP API so that you could easily attach to it anything you want, including rednet or any other set up, such as my project as well.

Also, you can use any socket to connect to a website, web sockets like I said are magic in the HTTP headers, so it would basically just be an addition to the HTTP api making connecting to web applications that use them a lot more simple.

The big point of websockets is that it allows HTTP to be Full Duplex.
immibis #18
Posted 14 March 2013 - 09:45 AM
Could someone give a better explanation for what web sockets would do in CC differently from normal sockets?

I think they would just be able to connect a socket to a website. Did you think they would be rednet sockets?
So what's different?
Dlcruz129 #19
Posted 14 March 2013 - 11:48 AM
Could someone give a better explanation for what web sockets would do in CC differently from normal sockets?

I think they would just be able to connect a socket to a website. Did you think they would be rednet sockets?
So what's different?

Absolutely nothing. It's a normal web socket.
martmists #20
Posted 20 July 2016 - 08:59 AM
I think I'm just gonna take ccSockets and update it to a newer version of CC
The Logo Maker #21
Posted 20 July 2016 - 04:44 PM
I think I'm just gonna take ccSockets and update it to a newer version of CC

you amazing.
SquidDev #22
Posted 20 July 2016 - 10:37 PM
I think I'm just gonna take ccSockets and update it to a newer version of CC

You might also want to look at CCTweaks (http://www.computercraft.info/forums2/index.php?/topic/21987-mc-1710189-cc-tweaks/) which provides a socket API.
Cloud Ninja #23
Posted 20 July 2016 - 11:50 PM
I think I'm just gonna take ccSockets and update it to a newer version of CC

You might also want to look at CCTweaks (http://www.computerc...0189-cc-tweaks/) which provides a socket API.
This is an option, or if you dont want to use another mod, you could take a look at HTTP to Socket, an API me and my friend developed. It allows both TCP and UDP socketting without the need for another mod. Although, it does require a webserver running it, but that could be done on your own computer, a raspberry pi, realistically anything that can run a webserver with a jsp applet container
Midnightas #24
Posted 15 August 2016 - 10:52 PM
I'd use the HTTP api for using my APIs on websites rather than sockets.
Edited on 15 August 2016 - 08:53 PM
immibis #25
Posted 11 September 2016 - 07:39 AM
I found out how websockets are different from normal sockets, by the way - they're designed for use by untrusted client code.

With raw sockets you could, say, connect to and SMTP server and send spam emails. With websockets, the server gets told that "this is a connection from ComputerCraft computer #13552", and it should reject the connection unless it's specifically intended to deal with requests from ComputerCraft computers.
masterex1000 #26
Posted 11 September 2016 - 09:07 PM
i would love this. think of using socket.io !