https://kotlinlang.org logo
#server
Title
f

ferdiafagan

06/21/2023, 4:11 PM
hello everyone 🙂 I am attempting to make with kotlin a desktop application that listens to port(s) for messages and returns responses (i.e. input output). It will only be handling requests from host user (from web browser). This seems like a tcp/ip application. I want to make this as lightweight as possible. From these requirements, ktor seems like possibly overkill for library choice . Using a jetty (not netty) or cio (avoiding http layer) seems like the most lightweight options . But maybe I should avoid ktor all together because it would be great to not use a servlet. My first solution (for mvp) was just a while loop that listens for messages on ports, and then I deserialized with code I wrote, etc. So what I am looking for is a library that could do this (that I wont have to maintain, and is hopefuly better then just a while loop) that does not use a servlet (because It is over kill)
a

Andrew O'Hara

06/21/2023, 4:13 PM
Http4k has a small 1 MB core module and can use the
SunHttp
server built into the java runtime. Might be worth looking into! https://www.http4k.org/blog/nanoservices/
My first solution (for mvp) was just a while loop that listens for messages on ports, and then I deserialized with code I wrote, etc.
Believe it or not, but I have actually seen this in production code. You may not mind the missing features of this approach, but the effort required to get and write the content you need and ensure it's robust might not be worth it.
d

dave

06/21/2023, 4:24 PM
We use sunhttp for low traffic servers for logging in CLI callbacks
It's works great and is really lightweight
f

ferdiafagan

06/21/2023, 4:40 PM
thanks @Andrew O'Hara and @dave
c

christophsturm

06/22/2023, 7:26 AM
I recommend vert.x if you want something low level
f

ferdiafagan

06/26/2023, 2:00 PM
@christophsturm would vert.x not be best suited for cloud / real distributed servers? not just a single node desktop server/application
c

christophsturm

06/27/2023, 8:36 AM
you said you are currently using a while loop so vertx with its event loop could be just perfect. and its not a huge library, sure it its mostly for servers but good performance is always great on the client 🙂
👍 1
f

ferdiafagan

06/27/2023, 8:03 PM
ok this is an interesting choice, definately will look into it and do some performance comparisons with simple example