Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

new to socket programming

 
ambrositti li
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, folks. Here is the partial spec of my first networking programming assignment.
GET: This message is sent from the client to the server, and contains the ASCII string GET followed by the newline character \n. On sending the GET message, the client waits for a return message from the server via the socket that connects them.
eg.
Client: GET
Server: GET: OK
A dog says woof
however, what i've got from the command line is like this:
Server: GET: OK
you see, the rest of the message(after the newline character) is missing. Could someone plz point me out what i did wrong. Thanx in advance.
below is the complete four classes i've come up so far and the text file(animalSoundData.txt) the server reads. it's all complied. please copy it to your own HDD and run it so you would know exactly what the problem is. thanx again!
P.S. i am sorry about the long post. please bear with me as i am desperately looking for the solution.
the server class

the client class

the protocol class

the helper class

the content of text(animalSoundData.txt)file:
dog:woof
cat:miao
cow:moo
snake:hiss
bird:chirp
[ April 12, 2004: Message edited by: ambrositti li ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the client, double check what's inside the loop "while((userInput = stdIn.readLine()) != null)" and what should maybe be outside the loop. That's a broad hint at one thing that may not actually be the problem. Lemme know if it helped!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic