Win a copy of Terraform in Action this week in the Cloud 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

strange results

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have just started learning socket programming in java. My programe has two part. one is client creates a message that is sended to server. Another is a server that recives the messages and then send back the message to client.
it work but has a strange result. the first char in the message, for sample "123", that sended from client to server,at server side, it's removed, so the result is "23", again the recived messages are sended back to client, so the result at client ":23". I don't know result.
has any one can help or explant ?
thank you !
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Impossible to see without code, but I'm willing to bet that it has nothing to do with your network programming per se -- check your stream I/O code to see if you're throwing away stuff.
- Peter
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are two probable reasons that I can think of:
1. The if you are using any buffer or an array for the i/o stream you are probably not flushing it. Check if the results vary. Rerun or call the sequence in a loop and read the data in a loop in the server side.
2. Or perhaps your code does not encode the data in the right charecter set. try encoding the data.
This can be better clarified if you can paste the code.
e.g. the type of OutPutStream object you are using and teh piece of code used to write to socket.
I hope this helps!

[ June 18, 2002: Message edited by: Abhijit Kulkarni ]
 
You showed up just in time for the waffles! 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
reply
    Bookmark Topic Watch Topic
  • New Topic