H
H
hasenovkirill2022-02-26 07:35:52
Android
hasenovkirill, 2022-02-26 07:35:52

How to properly prepare a socket server for an Android application?

1) Is it true that an Android application can send requests to an external server only via the http protocol, and cannot send requests via ws and wss. For example wss://example.ru

2) If the first statement is true, then how are socket requests to the server built, and how the server should process them. How can you connect to sockets via http request in general?

For example, using JS from a browser, you can connect to a socket server in the following way: How is this done in an Android application?
var socket = new WebSocket("ws://example.ru/ws");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolai Savelyev, 2022-02-26
@AgentSmith

1. No, not true. You can send not only via HTTP, but also via HTTPS, WS, WSS
2. Your first statement is not true.
Connecting via websocket is best done through a library, for example, OkHttp
https://camposha.info/android-examples/android-web...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question