html5 WebSocket - html

I already have a server with port and want to write a web app to get the information form the port. Will this be possible with WebPorts?
The Client doesn't even need to talk back to the server, which is the whole point of websockets I would imagine, but since I already have the ports setup, I might be easier and cleaner to just connect and get the info without having to refresh.

WebSockets are not intended as clear TCP channels over which other existing protocols can be implemented.
WebSockets are designed to allow messages to be sent between a client and server, where an event is raised each time a message is received.
Hence a WebSocket client cannot simply connect to an existing TCP server - that server also has to speak the WebSocket protocol.
You could of course write a WebSocket-based server that does nothing but act as a proxy to existing network services.

I think you want websockify which is a WebSocket to plain TCP socket bridge/proxy. It also allows sending and receiving of binary data with the older version of the WebSocket protocol which hadn't yet added direct binary data support.
Disclaimer: I created websockify.

Related

What is the role of websocket in webRTC?

I built the server into Java,The server sends (image)data to the web browser through a web socket.So far it works fine.
and I wand that The web browser send data from the server to another web browser (client) using webRTC, So I looked for the webrtc...
I noticed that there are occasions when you need to use webSocket with webRTC
What is the role of websocket in webRTC?
In order to establish a WebRTC connection between two browsers, these browsers will have to negotiate a connection first. To negotiate a connection they need to be able to talk to each other. But they cannot talk to each other because they have not established a connection yet.
That's where a signalling server comes in. That's a server that both peers are already connected to and which can relay messages between them until they have established a connection. Using a websocket connection for this purpose is the most useful way, since it's a (soft) realtime bi-direction communication channel, exactly what you want when relaying messages as quickly as possible.
It doesn't have to be a websocket though; AJAX and/or long-polling will do too, but they have more overhead and are slower, which means it will take longer to negotiate the WebRTC connection.

use and purpose of websocket multiplexing extension

I am trying to understand the purpose of websocket multiplexing extension, the main purpose what the document states is to use a single same origin physical websocket connection to the server while each browser tab uses a logical connection multiplexed on top of physical connection. I see another alternative using which we can accomplish this behavior today, the approach is to launch a shared web worker which opens the websocket connection and let each browser tab send and receive message to/from this worker. i have not tried this yet and i wonder will this work at all.
Your question reflects a misunderstanding of the problem the WebSocket Multiplexing Extension is trying to solve.
The base WebSocket spec (RFC 6455) defines a protocol for bi-directional exchange of data over TCP/IP. A WebSocket starts as a normal HTTP request / response. In this exchange, the client and server negotiate to switch to the WebSocket protocol. After the switch, the client and server exchange data frames over the TCP/IP connection. This creates a bi-directional data stream between client and server.
A drawback of the base protocol is that it supports only a single stream of data flowing in each direction. The multiplexing extension augments the base protocol, by allowing the client and server to create multiple "channels" over the same TCP/IP connection.
So the purpose of the multiplexing extension is to allow multiple WebSocket channels to run over the same TCP/IP connection. That's all.
Having multiple browser tabs (or web workers) share a single TCP/IP connection is just an example of how multiplexed websockets might be used. In standards terminology, it's just "informative" (descriptive), not "normative" (a required part of the spec).

NodeJS + HTML5 + Telnet = isitpossible?

I have this project for my classes i'm currently workin' on. here it is:
WebPage client for Telnet not on standard ports, with ability to choose a port and connect
I have machines with telnet servers on them, just waiting for connection.
So my idea was to set up a nodeJS with express server on a dedicated machine. This would handle connections through telnet and host a page for clients, that would use socket.io to exchange information with server side.
But as i'm new to such technologies (telecommunications student) i wonder if it is possible. I spotted something like this - jsterm.com by Peter Nitsch, but i see there are some massive gaps in code and the demo does not really work so i don't know if it actually works. Did anyone try this?
My other problem is - when i send information to nodeJS server through websockets, which seems achievable for me, what do i do with this information? Do i just set up another websocket to pass the same data i got from client websocket directly to the telnet port?
Can sockets connect directly to specific port, without any websocket waiting on the other side?
If my idea is wrong, could anyone help me - maybe there exists some nice solution - i was thinking about Anyterm for example but i see that it requires an apache server and runs completely different technologies...
Just to be clear, WebSocket connections are not raw TCP socket connections. They have extra header information in each packet, browser to server data is masked using a running XOR, etc.
In order for the browser to communicate with a normal TCP server (e.g. a telnet server) you will need some sort of bridge service. It just so happens that such a thing already exists. websockify is a server that accepts WebSocket connections and bridges them to a raw TCP server.
In fact, the websockify project already includes a working telnet client as an example application. However, note that one limitation of websockify (for security reasons) is that the client cannot pick an arbitrary server address/port to connect to. The target address(es) must be predefined, either as a single target specified on the command line for websockify, or as multiple targets specified in a configuration file (and selected via a token in the WebSocket connect string).
There are multiple implementations of websockify in different languages (python, C, node, ruby, Clojure) however, only the python version currently supports multiple targets via a configuration file.
Disclaimer: I created websockify.

Websocket authentication

I'm running a websocket server and asking myself, if it's planed, that clients authentication will be done with handshake in future... draft xxxx maybe :)
Do you have information? I have heard that with draft07 a session id can be sent to server, so maybe that can help to auth the client...
What I'm doing atm is to wait a maximum of 10 seconds, till the clients sends me a message with login header, username and password. But i think this is not "THE" solution. How do you guys out there doing it?
The WebSockets protocol permits standard HTTP authentication headers to be exchanged during the handshake. If you have a WebSockets server that plugs into an existing web server as a module then existing authentication in the web server should already work. Otherwise if you have a standalone WebSockets server then you may need to add the authentication support.
Update
As #Jon points out, unlike normal HTTP/XHR requests, the browser API does not allow you to set arbitrary "X-*" headers for WebSocket connections. The only header value that you can set is the protocol. This is unfortunate. One common solution is to use a ticket based system that relies on existing HTTP mechanism for authorization/authentication and then this ticket is passed along with the websocket connection and validated that way: https://devcenter.heroku.com/articles/websocket-security

Server and client side of sending an e-mail with SMTP protocol

I want to write both client and server sides of sending an e-mail also I should attend to the standard format of SMTP protocol which is specified in RFC 821.
Would you please help and guide me that how can I start it?
Why would you reinvent the wheel? There are many implementations for both sides that do a very good job and are well tested.
What feature do you miss in let's say Postfix (server) and Outlook (client)?
If you still want to start, ask yourself
how to create TCP Sockets and read/write to them
how to do connection and thread pooling
how to implement a state machine
what are you doing with related topics? (SPF, DKIM, mbox storage, Maildir storage)
what are you going to use for user authentication and authorization
(... enter hundreds of other things here ...)