473,405 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

client-server communication

65
in a server client communication which uses Socket and ServerSocket classes of java, think that client is sending some information byte by byte,
and server is reading in the same way (byte by byte), then replies.

what i cannot figure out is: when does the server start reading the bytes which are sent by client.
does it wait until all bytes arrived?
or does it immediately read when 1 byte is written to the related port.

or does this behaviour is determined by the streams used in communication
(DataInputstream, DataOutputStream etc...)?

or is it about flushing? (some streams may have auto flush or something like that)
Sep 19 '07 #1
1 1548
Nepomuk
3,112 Expert 2GB
in a server client communication which uses Socket and ServerSocket classes of java, think that client is sending some information byte by byte,
and server is reading in the same way (byte by byte), then replies.

what i cannot figure out is: when does the server start reading the bytes which are sent by client.
does it wait until all bytes arrived?
or does it immediately read when 1 byte is written to the related port.

or does this behaviour is determined by the streams used in communication
(DataInputstream, DataOutputStream etc...)?

or is it about flushing? (some streams may have auto flush or something like that)
I don't know, if it's so with all Streams, but I've made the experience, that when I send Byte per Byte with something like
Expand|Select|Wrap|Line Numbers
  1. byte[] bytes = new byte[1024];
  2. // Fill the byte array...
  3. outputStream.write(bytes);
  4.  
and receive with something like
Expand|Select|Wrap|Line Numbers
  1. byte[] bytes = new byte[1024];
  2. inputStream.read(bytes);
  3.  
I have correct data for quite a while, but at some point it starts to only have 0 0 0... What I do is, I wait, until the appropriate amount of Bytes are available with
Expand|Select|Wrap|Line Numbers
  1. while(inputStream.available < 1024)
  2. {
  3.     try{Thread.sleep(1);}
  4.     catch(Exception e){e.printStackTrace();}
  5. }
  6.  
and then read the array in. Of course, that can be done with single bytes too.

Greetings,
Nepomuk
Sep 19 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Chris | last post by:
<apologies for cross-posting> Hi All, I am based in the UK and have been doing some private work for a client which involved setting up a database and scripts to search it and display results...
2
by: Rhino | last post by:
I am trying to verify that I correctly understand something I saw in the DB2 Information Center. I am running DB2 Personal Edition V8.2.1 on Windows. I came across the following in the Info...
7
by: Nalaka | last post by:
Hi, I created a sinple web service that returns a dataSet. Then I created a client program that uses this web service (that returns the Dataset). My question is, how did the client figure...
11
by: pshindle | last post by:
We have several machines currently running the DB2 V7 Run-time Client that we would like to actually be running the App Dev Client. To 'upgrade' (within the same version) this client software can...
2
by: J Huntley Palmer | last post by:
I am having a horrific time integrating uw-imap's c-client for imap support in php. The problem is a whole bunch of "Text relocation remains referenced against symbol" errors during linking....
11
by: Wayne | last post by:
I am a one man enterprise and have been asked by a prospective client what happens to their database regarding ongoing changes etc if I get hit by a bus. Obviously my databases are distributed...
1
by: WebServiceSecurity | last post by:
The issue involves the following technologies: - 1. .NET 2.0 Framework 2. WSE2.0 (WS-Security) 3. X.509 certificates 4. BEA Weblogic 8.1.5
3
by: rjha94 | last post by:
Hi I just installed the runtime client on my windows machine. when i go inside the SQLLIB\bin folder i can see db2.exe. is it possible to use this db2 bundled with runtime client for command line...
4
MMcCarthy
by: MMcCarthy | last post by:
http://bytes.com/images/howtos/projectscope_blocks.jpgAs a freelance IT consultant for over 10 years, I’ve come to appreciate well defined project scopes. A project scope is a common understanding...
11
by: Bill Davy | last post by:
I am trying to edit Contacts in Outlook. This is so I can transfer numbers from my address book which is an Excel spreadsheet to my mobile phone. I came across the following snippet of code which...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.