https://kotlinlang.org logo
Title
k

krleg

05/03/2019, 9:49 AM
HI, everyone! I am student and just trying to understand kotlin programming language. Is there someone who can help me with app connection to TCP server using IP and port? I need to connect to the server and retrieve data from there. I am ready reading if someone has great material. I never have done this before, so I dont know from where to start.
d

Dennis Schröder

05/03/2019, 11:18 AM
Are you talking about raw socket or websocket? RawSockets: https://ktor.io/servers/raw-sockets.html WebSockets: https://ktor.io/clients/websockets.html
n

nfrankel

05/05/2019, 9:02 AM
how is that kotlin specific? the question is a bit large...
k

krleg

05/05/2019, 9:18 AM
This is a task - create android aplication using Kotlin programming language. Server side already has developed. I have IP and port number, and I need to create TCP connection. When connect to server, app need to send command "AUTHORIZE,
command "AUTHORIZE<email> and server will respond with "USERLIST<id>, <name> ..."
d

Dennis Schröder

05/05/2019, 9:24 AM
k

krleg

05/05/2019, 9:37 AM
I tried something like this, but it dont work.
d

Dennis Schröder

05/05/2019, 9:56 AM
What exactly is not working? Please read this for future help requests: http://sscce.org/
k

krleg

05/05/2019, 2:35 PM
In code above error was due to using main thread. So I created AsyncTask for socket. And now I dont understand what I have done incorrect- Cannot evaluate android.system.StructAddrinfo.toString. Do I declare ip address in socket incorrect?