This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing bytes out to a socket

 
Sally Molloy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am a compete greenhorn, no in fact that is probably being a bit generous. I am many years in software but have never even taken a single class in Java, just the way it happened - it didn't come up.
Now I am taking night course in security and the very lazy, arrogant lecturer won't accept the assignments in anything other than Java although "this is not a Java course" as he keeps telling us. So yes people this is homework, just not Java homework.
I need to write a client that takes in user input (string) opens a socket and sends it off as bytes to the server.
Through Googling and general hacking together of examples I have it compiled and talking to the server I was provided with but the server keeps producing an error claiming I am sending ASCII.
Everything I read, including on this site suggests I am sending the string converted to bytes....
Can anyone suggest what is going on??
I am literally begging for help on this one.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly do you mean the server "keeps producing an error claiming I am sending ASCII."?

Also, when you catch an exception, at the very least, print the stack trace. (That's not actually proper exception handling either, but at least you get to see details of the problem, and for educational exercises it's often good enough.)


 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, if you're just echoing text back and forth, why are you messing around with Data Streams and ByteArray Streams?
 
Sally Molloy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeff, thanks for replying.


I think I have left out some critical points in my explanation of what I am trying to do!
* I have to write to a server thats been provided as an executable so pretty much black box.
* The user is to enter any string when running the client and indicates end of entry by hitting return
* The client is expecting to receive this string as a byte array or byte stream??
* The server is outputting messages like "invalid type 48 in stream, expected 1". In the bit of blurb provided with the server this is listed as a common error and says you are still sending a string, not bytes???

Thanks for the advice onthe exceptions - I have changed that now but I am not seeing any output as I amn't encountering an exception
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic