473,765 Members | 2,021 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

client-server communication

65 New Member
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
(DataInputstrea m, DataOutputStrea m etc...)?

or is it about flushing? (some streams may have auto flush or something like that)
Sep 19 '07 #1
1 1559
Nepomuk
3,112 Recognized Expert Specialist
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
(DataInputstrea m, DataOutputStrea m 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
2298
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 etc, all the usual stuff. The work was at about the halfway point when the client asked for a time estimate for the whole project. I sent him this and he wrote back
2
4672
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 Center: To return a result set from a procedure to the originating application, use the WITH RETURN TO CLIENT clause. When WITH RETURN TO CLIENT is specified on a result set, no nested procedures can access the result set.
7
2928
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 out to create a "DataSet" as the return type from the webservice?
11
4212
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 we simply install the App Dev Client on 'top of' the Run-time Client? Will the install routine uninstall the Run-time Client under the covers during the install of the App Dev Client? Also, is this type of 'upgrade' possible/supported during a...
2
7577
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. Any help appreciated! The ordeal is a follows I am using Solaris 10 with php5.1.1. GCC:
11
2210
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 as mde files in an effort to protect my intellectual property. How do I give the client peace of mind, short of giving them a backup mdb file that any programmer could work on to provide required changes etc if I wasn't around? Of course this...
1
3422
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
2622
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 processing? Because all the documents tell you to get an administration/ application client to do such thing. Thanks - Rajeev.
4
9292
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 between you and your client as to what work is included in, or excluded from, a project.In a study done by CA towards end of last year, one third of all projects end up over budget and over-spend typically 10-20% of the original budget. Primary reasons...
11
7736
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 enabled me to the contacts at least list. I had to root around to discover CdoDefaultFolderContacts (though it was guessable; how could I enumerate win32com.client.constants?). I now want to work through the Contacts in Outlook patching in...
0
9568
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10164
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9835
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5277
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3926
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.