• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to send data in bytes from one ip address to other ip addres ?  RSS feed

 
priyanka barwad
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have code for source and client it works well in same machine but i want to do communication between two machines so i just want to know , is my code do this task? and please go through code once, if any part of code you want to change to perform this task please do. thanks in advance

clientprogram


server program


 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you considered a byte array output/input stream? Are you familiar with the networking sections of the Java® Tutorials?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are some problems with the code you posted.

In particular, the read and write methods might not read or write all the data. you should use these methods in a loop, and check the value returned by these methods (the number of bytes that have actually been read or written) until you are sure that all the data has been read or written.

See this page in our FAQ: Read Doesn't Do What You Think It Does
 
Liutauras Vilda
Sheriff
Posts: 4927
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
priyanka barwad wrote:i want to do communication between two machines so i just want to know , is my code do this task?

Have you tried to run it on a different machines? Probably it is the best way to find out "is my code do this task?".
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!