• 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
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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
 
Marshal
Posts: 22449
121
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

 
You're not going crazy. You're going sane in a crazy word. Find comfort in this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic