M
Mark Volkmann
I have the following basic code. When I run this it says "TCPServer
Error: Address already in use - bind(2)". I can hit Ctrl-C to kill it,
change the port to anything and rerun it and I still get that error
message. I must be missing something really basic.
require 'webrick'
include WEBrick
class AddServlet < HTTPServlet::AbstractServlet
def do_GET(req, res)
n1 =3D req.query['n1'].to_i
n2 =3D req.query['n2'].to_i
res['Content-Type'] =3D 'text/html'
res.body =3D "The sum of #{n1} and #{n2} is #{n1 + n2}."
end
end
server =3D HTTPServer.newPort=3D>2000)
trap('INT') { server.shutdown }
trap('TERM') { server.shutdown }
server.mount("/add", AddServlet)
server.start
Error: Address already in use - bind(2)". I can hit Ctrl-C to kill it,
change the port to anything and rerun it and I still get that error
message. I must be missing something really basic.
require 'webrick'
include WEBrick
class AddServlet < HTTPServlet::AbstractServlet
def do_GET(req, res)
n1 =3D req.query['n1'].to_i
n2 =3D req.query['n2'].to_i
res['Content-Type'] =3D 'text/html'
res.body =3D "The sum of #{n1} and #{n2} is #{n1 + n2}."
end
end
server =3D HTTPServer.newPort=3D>2000)
trap('INT') { server.shutdown }
trap('TERM') { server.shutdown }
server.mount("/add", AddServlet)
server.start