Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Not getting the bytes sent  RSS feed

 
vanlalhmangaiha khiangte
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

This thing has been bugging me for the last couple of days and am not able to find the reason why ...

Server Program :-



Client Program :-



This code when i run in a computers across a network the results are not consistent ...

I had run the server in one machine lets say 192.168.0.1 and i run the client in another machine 192.168.0.2


The bytes sent is sometimes received and sometimes it is not received ..

How do i increase the socket buffer size ?
How to sent all the bytes across the network without any loss ?
Any suggestion ...


Thanks in advance
 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should start by calling theOutput.flush() after each write.

Moving to IO.
 
vanlalhmangaiha khiangte
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob,
Have already tried that .. still same result ....
Sometimes even in same machine .. all the bytes are not sent ...

Thanks
 
Sev Zaslavsky
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Agree with Rob, you need the flush() and a close()on the client.

But I think the problem might be on the server. It appears you are detecting an EOF by looking for an exception at "in.read(b)" - it might be better to check for return value -1. Maybe the exception is causing some non-deterministic or simply unexpected behavior.
 
vanlalhmangaiha khiangte
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
Tried that part too ...
Client side change:-


Server side change :-


Client output :-
Creating client port
Finished:::30000
Client closed

Server output :-
Count 15069
Size:::0

No use ... still not getting the bytes ...

I had also tried TCP/IP window sizing ...
And increased the buffer size ... it worked to some extent but the problem is like this again ...

I think the buffer to where the sockets is writing and reading the data is getting full .. but i do not know how to see this value ...
If i can clear this buffer every time the data is read i think this can be solve ...
How to access this buffer ? How to clear this buffer ?
No idea

Please anyone .. any suggestion will be greatly appreciated ...


Thanks
[ November 19, 2008: Message edited by: vanlalhmangaiha khiangte ]
 
Sev Zaslavsky
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is here - you're calling in.read(b) twice



try this code I fixed up a little, but don't forget to change ip address

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!