Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Networking performance questions  RSS feed

 
Geoffrey Falk
Ranch Hand
Posts: 171
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have written an application that transfers data across a network using Socket, getInputStream(), getOutputStream(). I have some concerns about how to optimize for performance.

Currently I am writing one byte at a time to the OutputStream. I am wondering if this results in a separate TCP packet being sent for each byte, which would obviously be very inefficient. Or does it buffer the data into a packet before sending?

If I need to wrap my OutputStream, what is the recommended way to do it?

Thanks
geoffrey
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Geoffrey Falk wrote:. I am wondering if this results in a separate TCP packet being sent for each byte,


No. The OS is going to do some caching of its own. Of course, it is always better to make fewer API calls if possible. The online book Java Platform Performance has several techniques to optimize IO.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!