Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
Posts: 27
Registered: ‎12-18-2012
My Device: Z10, Playbook
My Carrier: Viettel
Accepted Solution

Socket address with parameter

Hi,

 

I want connect to Server by socket, so I use

 

QTcpSocket::connectToHost(QHostAddress(address), port);

 

but adress is URL as:  ws://abc.xyz:5050?param1=1234&param2=4567

 

if connect without param I do it OK, but with param I don't know how to set param for connection.

 

how to connect in this case?

 

Developer
Posts: 713
Registered: ‎05-31-2010
My Device: 8520
My Carrier: Movistar

Re: Socket address with parameter

You have to pass only the IP address and port

Establish the socket and send the parameters (the pair-value after ?)

Contributor
Posts: 27
Registered: ‎12-18-2012
My Device: Z10, Playbook
My Carrier: Viettel

Re: Socket address with parameter

thanks YamilBracho,
did you mean send by write() methode
Developer
Posts: 271
Registered: ‎05-29-2013
My Device: BlackBerry Z10
My Carrier: MTS

Re: Socket address with parameter

Sockets are used for communicating on rather low level. You can't pass them URL parameters. Are you sure that site you are trying to connect supports sockets?
-------------------------------------------------------------------------------
NSR Reader for BlackBerry 10 @NSRReader on Twitter
Me @xelfium on Twitter
Contributor
Posts: 27
Registered: ‎12-18-2012
My Device: Z10, Playbook
My Carrier: Viettel

Re: Socket address with parameter

[ Edited ]

Yes, my server suport websocket in this case,

and I try to use QTcpSocket and QWsSocket (websocket at here: https://github.com/ant-lafarge/QtWebsocket )

in both case I try to init connection with param but not as I expected.

are there any way to init websocket connection with URL:
ws://abc.xyz:5050?param1=1234&param2=4567

Highlighted
Developer
Posts: 271
Registered: ‎05-29-2013
My Device: BlackBerry Z10
My Carrier: MTS

Re: Socket address with parameter

You need to pass params according to communication protocol, supported by your server.
-------------------------------------------------------------------------------
NSR Reader for BlackBerry 10 @NSRReader on Twitter
Me @xelfium on Twitter
Developer
Posts: 713
Registered: ‎05-31-2010
My Device: 8520
My Carrier: Movistar

Re: Socket address with parameter

yes... Altough according your question is cleaner to use QNetworkAccessManager..