TCP/IP DataInputStream reads not all data send in one time?

I have a C program that sends 4104 bytes of data to a java client.
In my java client I have a buffer of 4104 bytes that reads the data using a DataInputStream. Now my problem is that the read function returns with only 1460 bytes instead of 4104 bytes.
I only have this problem on a new type of PC we are using.
Now I was wondering when you have a TCP/IP session doesn't every send results in 1 recv (read)?
Does this differ for various platforms? (is that buffer size adjustable)
Thanks!

Alright then I do have a problem.
If your application level doesn't define a blockthen
you have problems.So I have to keep reading on the socket untill I get a
timeout? I saw that DataInputStream has a function
available(), this should return the available number
of bytes that can be read without blocking. This
hardly seems to work?
I just want to read 1 TCP packet without knowing the
size or the protocol of the packet without having to
wait for some timeout. I don't want to reassemble -
defragmentate all my packets. This question seems very
reasonable to me, but perhaps I'm missing something?
There's no guarantee in TCP that a block size N
written in one application will be delivered as a
single block to the receiver.Is there a place I can read that specification?Usually people need to understand an API in order to be able to use it. TCP sockets present a continuous stream paradigm: the data stream starts when the connection is established and ends when the connection is closed. Now reread your own question: you want to read a block of data from such a stream without knowing the size of the block. That just makes no sense. It is like trying to read first X bytes from a file stream without actually knowing what X is. The number of bytes available immediately on a socket read is subject to all kinds of random factors on the network and has nothing to do with the amount of data the server is actually trying to send as a "block". That is, a single write() on the server does not necessarily correspond to a single read() on the client.
A common solution to this problem is to have an implicit block size (that is, it is fixed and known apriory) or prefix your payload with the block size. An example of the latter would be to send the block size as the block header (say, an int in network byte order) so that the receiving end could read the size first and then perform a loop that continuously reads from the socket until it reads exactly the required amount.
In other words, TCP sockets just provide you with a continuous stream paradigm. You need to impose some kind of an application protocol on top of it to build client-server dialogs. This is what's done behind the scenes by CORBA, RMI, HTTP etc.
If you need to read up on Berkely socket API specifically, Richard Stevens has written some excellent books.

Similar Messages

  • HELP iPhone 5 got reformatted while being updated. not all datas recovered from iCloud.

    I recently updated my iphone5 with iOS 7.0.3 but while updating it was reformatted. I tried to recover my apps and photos from iCloud but not all datas were recovered. I am sure that I was able to back up my phone regularly. Only new photos were recovered the older ones which were the first ones that I backed up cant be found. Can I still recover those datas?

    Restoring the backup should recover the photos that were in the camera roll at the time of the backup.  If that didn't happen, all you can do is try restoring the backup again.  You might try some of the tips mentioned in this discussion thread that other's found useful when they had a similar problem, such as the one by ezjules: https://discussions.apple.com/message/19518589#19518589.

  • Error "Not all data could be changed in LC" when running DP macro

    We are getting the error, "Not all data could be changed in LC" when running DP macros and we are not sure why. It seems to only happen when we are executing it via a Process Chain but not using the DP background processing scheduling. Does anyone know why this is happening?

    Hi Stacy,
                         I hope you are seeing this in message spool.  This message comes up for various reasons. We used to see a message saying "No data saved".
    Some of the reasons could be " the new value (lets say 3 ) after the macro execution is same as after execution (3)".
    See if some of the values are fixed and could not be changed.
    I would take a selection id with just few values and execute the job for that selection id and compare the pre and after results. That should answer all your questions.

  • Not all data could be changed in LC (Message no. /SAPAPO/TS007)

    Hi Experts,
    When I run forecasting through automodel(strategy 56) in the background, For some combinations I got the warning message "Not all data could be changed in LC" (Message no. /SAPAPO/TS007). What does this message means?
    Thanks & Regards
    Yogeesha

    Hi
    Logically whenever you create a new CVCs in APO system you should execute the job /SAPAPO/TS_LCM_CONS_CHECK
    by default which will assign time series for the newly created CVCs.
    In the following case, it looks like you have created CVCs and than during th FCST job as it does not found the time series for newly created CVCs you received the following errors.
    You can execute the report now which will fix the issue, but I will suggest to execute this once CVC job creation is done as regular process.
    Please let us know, if this helps to answer you question.
    Thanks & Regards
    Amol

  • Attribute Change Run aborted with an error :Not all data indexed for index

    Hi,
    I have an issue where the master data Attribute Change Run  aborted with an error pointing to the BWA:
    Attribute Change Run aborted with an error :Not all data indexed for index
    we tried to load only 0 data into it,the error still occured.

    Detail message is following:
    not all data was indexed for index 'GBP_BIC:XYCH_098('0' for '114')
    creation of The BIA INDEX for infocube 'YBC_SD015' terminated while filling

  • How to export all the projects at one time

    I got about 20 projects and content about 7000 pics. I don't want to just export project each time, and I would like to just export all of them at one time, is it possible?
    I don't know where and how to change the name of the master files, and how to organize them properly. Such as I dragged pics from one project to another album, but if I try to delete the pic in the project, it warns me I will delete the master file as well. In the end, I have so many unwanted pic in the project and I can't delete them. Please help with the organizing ...

    Let's start from the whole story. I got too many photos and too many project which taken too much spaces in my computer. So I want to delete those not too good ones and only keep a few in my laptop. On the other hand, some of those not too good ones I want to keep as well. So I use time machine to back up them, but it seems time machine only keep them for about 3 months. In that case, if I delete them, I don't think I would be able to find them after 3 months time.
    I am thinking about exporting them to an external hard drive as an extra backup.
    Now, another part of the story, I was exploring Aperture, setting up different projects, album and dragging the pics around, then everything becomes a mess. I notice that if I drag a photo from project A to B, then the photo will only appear in B but disappeared in A. But if I drag photo from Project C to album D, both of them would have the pic, delete the pic either in the project or the album, it will warn me that I will delete the master file... I don't know how come.
    Therefore, puzzled by where and how they store the master file and how they referenced it, I am here.

  • How many character my iphone 4S can send at one time

    How many characters my iphone 4s can send at one time?

    A lot.  I'm not aware of any upper limit in an iMessage.
    For text messages, that would be a function of the carrier, I would think.
    And if you did send a message that was longer than the maximum amount ofr a single message, it would simply break up into two smaller messages.

  • Name and city not defined in FB60 for one time account

    Hello Guru's ,
    We are on SAP ECC 6.0 and I have defined a one time vendor in the standard account group CPD One-time vend.(int.no.assgnmt).
    In the screen layout for that account group I have the address details for name1 and postal code, city defined as optional entry. In the master data of the one time vendor I have however created an address so the address details like Name1 and City are filled.
    When I use MIRO for creating an invoice the address details are filled for the one time vendor, but when I use FB60 it prompts the following message: 'Enter a name and city for one time postings'.
    Why are the address details not filled in transaction FB60 while the have been filled in MIRO ? And why can I not post the Invoice as I have defined the name and address as optional entry in OBD3 ?
    Thanks as ever for your reply's

    Yes I understand that. The problem is however that we have invoice scanning and when the invoice is scanned it comes into the rework fase where we enter the one Time vendor. In a normal situation the invoice wille be created and parked (status completion) after which AP clerks can either enter a Purchase order or not. With the One Time vendor I don't get an invoice document as it prompting for the Name and City. Becaue of that I entered the name and city in the vendor master data and set them to optional in OBD3. Nonetheless it still gives me the error. Also in transaction FB60. So if it doesn't work with making fields optional in the vndor accoutn group and entering the requested data in the vendor master data I probably must set the error message some where into a waring ? Funny thing is that it does work for the MIRO transaction as I am not getting the error there.
    Thanks
    Edited by: Antoinette Stork on Jun 19, 2009 2:46 PM

  • Read data from Oracle , not all data brought over

    I have a strange problem when read data from Oracle and save to SQL Server.
    For example , there are 20k rows of data in Oracle , I created SSIS data flow, and data saved in SQL Server , Everything looks fine. But late you will find only first 16k rows of data in SQL Server , the rest is simple missng. no error or any waring. 
    I am using OLE DB .
    Great appreciate for any help.
    Ray

    Thanks. I think that UseSessionFormat=true
    helped me fixed this kind of issue in my other project.
    I actually found out this issue for this case I was asking. I am actually not missing data. It was a data type issue. A column was using a wrong datatype, so when I run a query and didn't get result I supposed. 
     

  • File Adapter - Reading 2 files from sender and one file to receiver

    All - I am looking for a best solution for reading two files from sender and generating one file to the receiver.
    Here is the scenario
    Sender file s - A is a master file. B is a detail file; B will have a one to many records for each record of File A.. that is the relation ship between 2 files..  I am looking for a better solution to
    Example
    Input:
    File A will have a record like "summary1 ABC 1234"
    File B will have a record like "Detailfor Summary1 CDF 8679"
    Output:
    File C shall have a record "consolidatedofSummary&Detail ABC 1234 8679"
    1) read records of master row and detail row from these 2 files
    2) do the mapping to the receiver output format which it is creating for records with some harcoded values and based on the values from master and detail rows of sender file
    if I can accomblish reading sender files and do the mapping to the receiver , assume that mapping to the receiver format would not be cumbersome.
    please help me...
    Thanks

    Hi Gopal,
    Ur approach to the interface is perfect.... Go ahead.
    For selecting multiple files in source use Advanced Selection for files.. and specify the directory paths and also the file name shema...
    This will fetch the 2 files into the integration engine... then u map the 2 source files to one target file(2:1 mapping).
    Specify accordingly the receiver side FCC and test it end to end...
    If u face any prblm post here... some1 will help u out..
    Babu

  • I just got my new iPhone4 set up today and it has pulled in every email that is in my desk top as being unread.  Yet I have read all the emails.  Still the iPhone thinks they are unread.  Does anyone know how I can delete all of these at one time?

    I just got my new iPhone4 set up today and it has pulled in every email that is in my desk top as being unread.  Yet I have read all the emails.  Still the iPhone thinks they are unread.  Does anyone know how I can delete all of these emails at one time from the phone?

    I have taken it back to the Apple store genius bar, but they say they don't see anything wrong. Well unless you use it all day and experience the problems when they happen, you wont see anything wrong. But there are lots wrong with it. But this would be the same store as I purchased the phone. And they backed up my old Iphone 4, but were not able to get anything to load back onto my new phone. So, I lost pretty much everything. But over time, some of my contacts have started showing up, although i am still missing over 800 of them.

  • Need Loop - All data elements in one section

    Guys,
    Below is the XML file I have with one section "Payment_History_Vendor" and all data elements present under it. The mailing name, address line 1 and addressline2 are changing. I need the output as below.
    Mailing_Name_ID6
    Address_Line_1_ID8
    Address_Line_2_ID9
    =========================================================================
    <R4425>
    <Payment_History_Vendor>
    <AddressNumber_ID3>518255</AddressNumber_ID3>
    <Address_Number_._._ID4>Address Number . .</Address_Number_._._ID4>
    <Mailing_Name_ID6>BROTHERS MASONRY INC</Mailing_Name_ID6>
    <Mailing_Address_._._ID7>Mailing Address . .</Mailing_Address_._._ID7>
    <Address_Line_1_ID8> RAYMERT DRIVE</Address_Line_1_ID8>
    <Phone_Number_._._.__ID11>Phone Number . . .</Phone_Number_._._.__ID11>
    <Phone_Number_Entry_ID13>( ) -</Phone_Number_Entry_ID13>
    <Address_Line_2_ID9> VEGAS, NV 0000</Address_Line_2_ID9>
    <Fax_Number_._._._._._._ID12>Fax Number . . . . . .</Fax_Number_._._._._._._ID12>
    <Letter_Date_ID16>Letter Date</Letter_Date_ID16>
    <LetterDate_ID17>September 30, 2009</LetterDate_ID17>
    <Date_Phrase_ID18>Date Phrase</Date_Phrase_ID18>
    <DatePhrase_ID19>2008 and/or January 2009</DatePhrase_ID19>
    <Start_Year_ID20>Start Year</Start_Year_ID20>
    <StartYear_ID21>2009</StartYear_ID21>
    <AddressNumber_ID3>517468</AddressNumber_ID3>
    <Address_Number_._._ID4>Address Number . .</Address_Number_._._ID4>
    <Mailing_Name_ID6> FIRE PROTECTION, INC.</Mailing_Name_ID6>
    <Mailing_Address_._._ID7>Mailing Address . .</Mailing_Address_._._ID7>
    <Address_Line_1_ID8>PO BOX 33409</Address_Line_1_ID8>
    <Phone_Number_._._.__ID11>Phone Number . . .</Phone_Number_._._.__ID11>
    <Phone_Number_Entry_ID13>( ) -</Phone_Number_Entry_ID13>
    <Address_Line_2_ID9>VENTURA 93007-0000</Address_Line_2_ID9>
    <Fax_Number_._._._._._._ID12>Fax Number . . . . . .</Fax_Number_._._._._._._ID12>
    <Letter_Date_ID16>Letter Date</Letter_Date_ID16>
    <LetterDate_ID17>September 30, 2009</LetterDate_ID17>
    <Date_Phrase_ID18>Date Phrase</Date_Phrase_ID18>
    <DatePhrase_ID19>2008 and/or January 2009</DatePhrase_ID19>
    <Start_Year_ID20>Start Year</Start_Year_ID20>
    <StartYear_ID21>2009</StartYear_ID21>
    <AddressNumber_ID3>518263</AddressNumber_ID3>
    <Address_Number_._._ID4>Address Number . .</Address_Number_._._ID4>
    <Mailing_Name_ID6> LINE MECHANICAL </Mailing_Name_ID6>
    <Mailing_Address_._._ID7>Mailing Address . .</Mailing_Address_._._ID7>
    <Address_Line_1_ID8> VALLEY VIEW BLVD., SUITE</Address_Line_1_ID8>
    <Phone_Number_._._.__ID11>Phone Number . . .</Phone_Number_._._.__ID11>
    <Phone_Number_Entry_ID13>( ) -</Phone_Number_Entry_ID13>
    <Address_Line_2_ID9> VEGAS, NV 102-0000</Address_Line_2_ID9>
    <Fax_Number_._._._._._._ID12>Fax Number . . . . . .</Fax_Number_._._._._._._ID12>
    <Letter_Date_ID16>Letter Date</Letter_Date_ID16>
    <LetterDate_ID17>September 30, 2009</LetterDate_ID17>
    <Date_Phrase_ID18>Date Phrase</Date_Phrase_ID18>
    <DatePhrase_ID19>2008 and/or January 2009</DatePhrase_ID19>
    <Start_Year_ID20>Start Year</Start_Year_ID20>
    <StartYear_ID21>2009</StartYear_ID21>
    </Payment_History_Vendor>
    </R4425>
    ========================================================================
    Thanks,
    Vijay Vattiprolu

    IMHO the best way is to change logic of program which generate xml
    it's better because
    - in package (as example of program which generate xml) you can contain full logic
    - in template you will have only loop by tags
    - simple maintain
    for your case
    - simple package (as example of program which generate xml)
    - in template complex logic which depend on many factors as example version of bip
    - very complex logic in template which imply hard maintain
    btw
    above structure
    >
    Mailing_Name_ID6
    Address_Line_1_ID8
    Address_Line_2_ID9
    >
    more simple then in Sections on Same Hierarchy, Regroup the data
    and it can be realized by cycle

  • Hide views in MM01 for all material type in one time

    Hi,
    I have a requirement to hide the views for all material type at at time.
    i tried with OMS2 , it is allowing me to do for one matrial type.
    could any one tell me how to hide the views for all material type in one short.
    Thanks in adv..

    Hi Rakesh,
    Up to my knowledge it is not possible to do view setting for all material type in one shot simply because it is material type dependent.
    If trying to change fields in material master then use OMS9. This also material type linked to field reference group. And we can change the setting of field selection group in one shot. This will affect the material types linked to it.
    Hope it helps
    sBk

  • Reading notes tab data in CRM_MKTPL - urgent

    Hi all,
    we are displaying CRM_MKTPL data in our smartform. Now our customer wants to display the data written in Notes tab in this form. How can I read the text that is written in Notes tab? By which class, which method?
    Can you help me?

    Hi Astron,
    Use FM Read_Text for the same purpose.
    Best Regards,
    Pratik Patel
    <b>Reward with Points!</b>

  • Not all data on contact syncs to the iCloud

    I have many notes within my contacts in my address book. Since upgrading to icloud, only some of the data within the notes field is syncing. The worst part is, since it syncs half the information to the cloud and then syncs the incomplete contact card back to my mac it permanently erases the data!
    Has anyone noticed this problem? Does it seem possible that I have identified the issue correctly?

    Welcome to the Apple Community.
    I assume you mean sync, not backup.
    First check that all your settings are correct, that contact syncing is checked on all devices (system preferences > iCloud on a mac and settings > iCloud on a iPhone, iPad or iPod).
    Make sure the contacts you are adding are added to your 'iCloud' group and not an 'On My Mac', 'On My Phone' or other non iCloud group (you can do this by checking in groups), non iCloud contacts will not sync.
    If you are sure that everything is set up correctly and your contacts are in the iCloud group, you might try unchecking contact syncing in the iCloud settings, restarting your device and then re-enabling contact syncing.

Maybe you are looking for