Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

servlet for implementing socket connection

How do I implement a web application with a Servlet that is listening on a port for socket connections?

like image 547
Kevin Boyd Avatar asked Jul 26 '26 19:07

Kevin Boyd


1 Answers

Having the servlet open ServerSockets is a bad code smell. This is primarily because it is the container's responsibility to manage sockets (among other resources like worker threads, sessions etc).

That said, I do not think you need a servlet in the first place. Unless you want to access some of the container's services, it would be better if you use a J2SE application to manage ServerSockets.

like image 85
Vineet Reynolds Avatar answered Jul 28 '26 09:07

Vineet Reynolds



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!