Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

General confusion with threads & sockets  RSS feed

 
David Ward
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a few specific questions but also looking for pointers /pitfalls etc with this client/server app I'm writing. It is coursework so pointers and further reading are greatly appreciated!
Basically this program has a client which reads data in about a patient, then sends it to a server app which does some magic afterwards with it. It should send the data at set intervals, 5 seconds in this case.

The pitfalls Im looking for will be later on once I'm attempting to scale this up to several Clients

Server code


Client code


So, on my Server app, I'm correctly seeing the values passed from the SensorArray ( client) but as mentioned in the code comments it seems like I'm constantly recreating the socket rather than keeping it open and just sending the variables across. Is this right?

I know I still have to add some graceful exceptions and closes too,

TIA for any advice.
 
gyank kannur
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was testing the client code, is there a possibility to take the input from system.in instead. Its easier to understand, something like below
 
gyank kannur
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also have a look at a similar threading based implementation below from one of our ranch users
http://www.coderanch.com/t/647363/Web-Services/java/restrict-website-proxy-server
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!