StreamingSocket WebSocket connection


#1

Is it possible to connect to a standard WebSocket host using the "ws" (ws://) prefix/scheme?

My host url looks like this:

ws://ws.pusherapp.com:80/app/APP_KEY?client=juce&version=0.1&protocol=6

 

I'm trying to connect to the following service: http://pusher.com/docs/pusher_protocol#websocket-connection , looks like they are using a standard WebSocket protocol.

StreamingSocket::connect()

returns false.

looks like

getaddrinfo

is the culprit.

Without going in too deep, is connecting to such a URL possible?

 

Thanks

 


#2

​Hello

​For a StreamSocket connection the protocol layer behind a raw connection is not relevant.

​String address;

socket->connect (address, 80 )

​You need the IP address here in "address" or the URL and the URL here is "http://pusher.com".

It make no sense to connect with StreamSocket. This is for raw TCP/IP connection stuff and you must implement the
the protocol layer for your own.

I mean the push service work with HTTP protocol layer on port 80, so the "URL"  (juce_URL.cpp) class make for sense for your request.


regards

​elli


#3

The url is: ws://ws.pusherapp.com. I'm not sure I understand what I can do with the juce::URL class. I think juce::StreamSocket is meant for exactly this is it not?


#4

So this URL indicates that a special protocol is running like ftp://, http:// git:// …
The juce::Url class is a specific class for HTTP protocol. When I’am not wrong than inside this class is a HTTP PUT and GET request. So you send an request to server and receive the response.

When you can get the raw IP address (with DNS calls) you can connect with StreamSocket to this URL. After this you must implement the pusherapp protocol for communication. But for this details I have no knowledge.

regards
elli