Question

I am writing a simple java web server for my practical which receives GET requests and returns the requested file contents. It seems to work fine, I am able, for example, to access files from the browser. I also wanted to try testing the server through the Terminal window by manually connecting to the server and sending the requests. So I write nc 127.0.0.1 6788 and then the request. Is it right that I have to connect again on every before every request?

I am new to this... Thanks in advance!

Was it helpful?

Solution

Connecting to a server basically depends on the protocol that you are using and the way your client has been programmed. When you use TCP protocol, a connection needs to be established (of course!)

Assuming that your client program requires only one file at a time, then for every file that you need, you will need to establish a new connection to the file server.

But if you want to stay connected to the file server to accept more than one file, then you need to program your client accordingly. Its just like how server programs are programmed to always listen for clients using for(::) or while(1) type looping statements.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top