Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Seemingly inconsistent socket behaviour  RSS feed

Mark Smith
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been tasked with programming a web server so that web admin can be done on a server application. Being all "test-infected", I'm trying to program a test to ensure that the web server responds correctly by using junit. Within the setUp procedure, I create a separate process (which I retain for later so that I can shut down automatically) and start the web server. I then create a socket connect to the webserver locally. I then send a 'GET' command to the server. It processes it and sends the appropriate web page.

Now my problem is that when I start up the web server from within the test class, it always only gives me about half the data and blocks trying to receive more. If I start the webserver outside of my test class, then it gives all of the correct data and executes perfectly.

It doesn't seem to be a matter of giving the web server enough to load as it always responds with data, just not all of it. I've tried putting Thread.sleep() after loading the webserver in order to give enough time to load. As yet, I'm not changing any of the default settings on the socket so I'm hoping this is where the problem lies.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!