• 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
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

Not getting the bytes sent

 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 22258
119
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic