|
-
December 17th, 2003, 10:07 PM
#4
Member
Hi,
I would really like to devote more time to working on your problem, but I'm at work right now, I'll try to take a more in depth look at it later. I do, however, have a question and a suggestion. When you say that nbtstat doesn't "recognize" your server, what do you mean? Does your program hang? Does an error generate a stack trace(although I'm sure you would have posted that)?
The program itself looks sound, however there is one thing that I noticed. Your problem may have less to do with java.net, and more to do with java.io. Assuming that your ServerSocket is actually creating a Socket object from its accept method, then the problem may lie with in the netmultithread's implementation of the run() method. You can see that the program is using a BufferedReader Object to handle the incoming I/O. In particular, the readLine() method is used to get the data from the inputStream. readLine() is a method used for receiving text data, which is why when you telnet into port 139 with your server running and begin typing ascii charcters, you get a response.
I think there may be a good chance that the nbtstat program that you run at the command line does not try to send a text stream, but rather a byte array containing data that is better received on your end by using a DataInputStream. You can use a DataInputStream to read raw bytes from your Socket's inputStream using either the read(byte[] b) method or the readFully(byte[] b) method. The DataInputStream is a member of java.io.
Basically, I am suggesting that you try and replace the BufferedReader with a DataInputStream and instead of readLine() use the read(byte[] b) method. You can still interpet ascii characters from the byte array, it will just take a little more work. I could be totally wrong, but I will look into this later. good luck.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|