This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

java Socket error

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I having trouble running this code. This java class containing this code gets compiled into a jar and uploaded into another application and it runs within that. So I have limited debug capability. Please help.
 
Saloon Keeper
Posts: 6511
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What kind of trouble? Which parts of the code are or are not being executed? Any error messages?

Also read http://test.javaranch.com/ulf/apple-java-tech-notes/Tech%20Notes/tn1157.html - your code suffers from this by using "readLine()".
 
Mahesh Narayanan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I modified the code a little bit. Now it runs for one iteration (i want to run in loop) and then gives a null pointer exception at line 80 (readline()). The other end is a vbscript code that pushes to this socket.

Edit: formatted code
 
Rancher
Posts: 4614
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might need to sort your indentation out.
It's hard to see the flow of the code.
Is there any other stack trace in your logs?
Because the only way that 'in' would be null was if there was an IOException earlier.
 
Tim Moores
Saloon Keeper
Posts: 6511
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error handling in this code is seriously defective - if there's a problem in line 13, the code should quit. If there's a problem in line 22, the code should quit. In both cases the code proceeds - that's not going to work.
 
If you try to please everybody, your progress is limited by the noisiest fool. And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic