• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Writing bytes out to a socket

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic