Problem in saving...

int packetsize=65536;
byte buffer=new byte[packetsize];
i use the above code to create a buffer where data from socket to be saved and then through a stream to store them into a file.
the problem is that if i send a packet bigger than 65536 packet...the file is completed but not correctly although the totalbytes are the same size with the totalsize of the file in disk...
is there a problem storing more than 65kb each time a packet comes?
p.write(buffer,0,packetsize);
p.flush();
this is how i save the packets...

Hello stefanosn,
For TCP connection we use ServerSocket at server side and Socket at client side.
Following example might help you
Server.java
import java.io.*;
import java.net.*;
public class  Server
     public static void main(String[] args) throws IOException
          int PORT = 8134;
          InputStream inStream;
          DataInputStream inDataStream;
          OutputStream outStream;
          DataOutputStream outDataStream;
          String message="";
          String received="";
          System.out.println("Chat Server Started");
          ServerSocket sock = new ServerSocket(PORT);
          Socket conn = sock.accept();     
          do{
          inStream = conn.getInputStream ();
          inDataStream = new DataInputStream ( inStream );
          message = inDataStream.readUTF();          
          System.out.println("Client sent: "+message);
          DataInputStream dis = new DataInputStream(System.in);
          message = dis.readLine();
          outStream = conn.getOutputStream();
          outDataStream = new DataOutputStream (outStream);     
          System.out.println("Enter your message here: ");
          outDataStream.writeUTF(message);     
          }while(!message.equals("bye"));
          conn.close();
Client.java
import java.net.*;
import java.io.*;
public class Client
     public static void main(String args[]) throws IOException
          int PORT = 8134;
          InputStream inStream;
          DataInputStream inDataStream;
          OutputStream outStream;
          DataOutputStream outDataStream;
          String message = "";
          InetAddress host = InetAddress.getLocalHost();
          String diffHost = args[0];
          Socket sock = new Socket(diffHost,PORT);
          System.out.println("Chat Client Started");
          do{
               System.out.println("Enter your message here: ");
               DataInputStream dis = new DataInputStream(System.in);
               message = dis.readLine();
               outStream = sock.getOutputStream();
               outDataStream = new DataOutputStream (outStream);          
               outDataStream.writeUTF(message);     
               inStream = sock.getInputStream ();
               inDataStream = new DataInputStream ( inStream );
               message = inDataStream.readUTF();
               System.out.println("Server Sent: "+message);
          }while(!message.equals("bye"));
}Compile, run .
i think you can get better idea.

Similar Messages

  • Problem with saving a pdf file to computer. Continually get an error message " This document could not be saved. There was a problem reading this document (21).

    Need advice on a saving file issue. I'm having problem with saving a .pdf file to computer. Continually get an error message " This document could not be saved. There was a problem reading this document (21). This is new as this error message just recently started to pop-up.

    More information about this issue can be found here:
    https://forums.adobe.com/thread/1672655
    A "quick" fix that worked for me was to uninstall Adobe... then download the base install for Adobe Reader 11.0.
    Then download each of the individual updates and run them sequentially. 
    I've installed back up to the last security update which is version 08 and have been able to do normal Save As operations.
    You will have to disable automatic updates in order to stay at version 08 until Adobe resolves this issue in a later release.
    http://www.adobe.com/support/downloads/product.jsp?product=10&platform=Windows
    Adobe Reader 11.0 - Multilingual (MUI) installer    AdbeRdr11000_mui_Std
    Adobe Reader 11.0.01 update - Multilingual (MUI) installer    AdbeRdrUpd11001_MUI.msp
    Adobe Reader 11.0.02 update - All languages    AdbeRdrSecUpd11002.msp
    Adobe Reader 11.0.03 update - Multilingual (MUI) installer    AdbeRdrUpd11003_MUI.msp
    Adobe Reader 11.0.04 update - Multilingual (MUI) installer    AdbeRdrUpd11004_MUI.msp
    Adobe Reader 11.0.05 security update - All languages    AdbeRdrSecUpd11005.msp
    Adobe Reader 11.0.06 update - Multilingual (MUI) installer    AdbeRdrUpd11006_MUI.msp
    Adobe Reader 11.0.07 update - Multilingual (MUI) installer    AdbeRdrUpd11007_MUI.msp
    Adobe Reader 11.0.08 security update - All languages    AdbeRdrSecUpd11008.msp

  • Problem while saving date field in custom table

    Hi,
    Iam facing the following problem while saving a date field in custome table
    i have a date field zdate in which the value is 02082010.
    now when i try to insert this value in the custom table it is getting updated as 20/10/0208 , but it should be 08/02/2010
    How can i correct it..
    Regards
    Kumar

    just before saving u might have to use a string reverse FM and then save it..
    CALL FUNCTION 'STRING_REVERSE'
      EXPORTING
        STRING          = p_string
        LANG            = sy-langu
    IMPORTING
       RSTRING          = r_string
    EXCEPTIONS
       TOO_SMALL        = 1
       OTHERS           = 2

  • Problem when saving form in web dynpro abap application in se80

    Hi,
    I am trying to develop an adobe application. When I save the form which i have designed.
    I get the "error" unable to convert data and the transaction is terminated.
    I dont have any idea why.
    Help
    Thanks,
    Harish

    Hi
    Are you getting the problem  while saving the Adobe form  or while saving the webdynpro application.
    Could you please elaborate your problem.
    Regards
    Naresh

  • Problems with saving edited photos using Photoshop Elements 5.0 on WIndows 8.

    Since a week I can not save the edited photos - when I try the communicate: "Caould not complete your request because of a program error" appeares. I had no problem with saving edited photos before, with the same software. My computer runs on Windows 8, 64 bit version. My Photoshop Elements is version 5.0. Where is the problem?

    W dniu 2013-06-16 15:36, dj_paige pisze:
    >
    Yes, I did it long ago.

  • Problem in saving values to DB

    Hi,
    i'm a new bie to BSP. Currently i'm facing some problems in saving the values to DB
    I'm assigning value for a html hidden field in VBScript, how do i save the same in the SAP database.
    Thnx in Advance
    Vinodh

    Hello, welcome!
    Second please check out this weblog:
    <a href="/people/brian.mckellar/blog/2004/06/11/bsp-trouble-shooting-getting-help">BSP Trouble Shooting: Getting Help</a>
    Third, check out in transaction SE80 the BSP Application SBSPEXT_HTMLB and look at the one for inputField.
    Then I would highly recommend checking out this weblog series: https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/exploring%20bsp%20development%20and%20the%20miniwas.htm
    It's a complete tutorial including saving to the DB.

  • Problem in saving ztable from va01 screen through exit

    Hi all,
    I am facing problem while saving ztable through additional data b tab screen of va01.
    Actually I have add table control in tab and on the basis of vbeln i am saving table control data in ztable.
    but all data saved except vbeln.. why it's happening? I have applied conversion also and it's showing in debug mode.
    but in table vbeln field is not appended. vbeln is primary key in my ztable.

    Hi,
       follow these steps:
    1. Create your table and add it through Append Structure in VBAK table.
    2. Create screen in Additional Data B.
    3. Field should be dic object
    4. Save and activate both Table as well as your Screen.
    Save data automatically inserted into your custome table. I did it and it is working fine.

  • Problem in saving project frm labview 8.5 to 8.2

    i m facing problem while saving the project frm 8.5 to 8.2
    while doing this i recieve message of following Vis missing
    1 Teststand-ExecuteMenu Command.vi
    2.Teststand-Insert Command in Menu(Execution View Manager.Vi
    3.Teststand-Insertcommand in Menu (SequencefileView Manager .vi
    4.Teststand-Insertcommandin Menu.vi
    5.Teststand-Remove Command from Menu.vi
    plz solve this problem

    Hello Eler,
    I'm the AE from the french support who tested your class.
    I tested your big class with different version of LabVIEW and with all the versions, I had the error.
    I tested with LV8.5.1 french, LV 8.2.1 french and english, LV8.2 french and english,LV7.1 fench.
    For me with LV 8.2.0 english version your class doesn't work.
    I attached screen shots for all tests.
    Regards  
    VéroniqueD
    NI France
    Attachments:
    error assembly.zip ‏382 KB

  • Problem in saving mkpf through migo additional tab screen

    Hi all,
    I am facing problem while saving mkpf table through some zfields added in extra tab at header level. i have append structue in mkpf. and implement screen through mb_migo_badi. i have searched a lot on sdn. but nothing is available regarding updation of mkpf. all says that we have saved data in ztable. cann't we save in mkpf table . if yes then what i have to do for it..

    Hi,
    You can find data in these tables when quality checking is done, these needs to be set by functional consultants.
    Chekc your process if any Inspection lots size is defined for each each goods movement at all, if not these tables will not be populated at all.
    Regds,
    Mano Sri

  • Problem in saving Inventory

    Dear All,
    I am under a process of installing 9.2.0.8 on 9.2.0.6 ORACLE_HOME, i have started the process a few mins ago, suddenly an error came its says :
    Problem in saving Inventory. Installation cannot continue
    /ebiz/oracle/oraInventory/ContentsXML/comps.xml (Permission Denied)What is this problem,, i have started this installation with Oracle User only,,, Please help me ......
    I have checked that file "comps.xml" its belongs to applmgr user (application user).. how do i change this file permission,, if i change this installation will move on !!!
    Regards
    HAMEED
    Edited by: Hameed on Jul 23, 2011 2:18 AM

    Thank u dear,, after changing the permission i started again,, and completed successfully.
    but failed with some other issue.. kindly follow this below link
    Re: Application Intraoperative patch needed for DB version Upgrade in 11i ?
    Regards
    HAMEED

  • Problem in saving image to jpg

    Hello.
    I've got a problem in saving a LabView Picture in a jpg File.
    The picture id grabbed from a DirectX Livestream from a camera.
    Then I want to save it in a jpg file using the Standard LabView Functions.
    But all I get is an empty jpg File and an error:
    Check_Data_size.vi
    Error 1
    I'm using LabView 7.1.
    Has anybody got an idea how to solve the problem?

    No.  You can save a gray image to jpg, but I has to be 24 bit.
    Try save your data to bmp.  If you got the same problem, that means you fail to wire correct data format to the LabVIEW VI you're using.
    George Zou
    http://gtoolbox.yeah.net
    George Zou
    http://webspace.webring.com/people/og/gtoolbox

  • Problem in saving modified rtf file in jsp

    hi,
    I have [b]problem in saving modified rtf file in jsp. My scenario is like this:
    I need to open rtf file in jsp and allow user to modify it, after user modifies rtf file in browser, user will press send button. After user pressing send button rtf has to be saved into destination directory(the directory from which its been fetched. I appreciate if any one could send me relevant code for the same.
    thanks
    ram

    1) RTF is not opened in your browser, but in an application that is set to handle the file type (like Word or Wordpad)
    2) from the web you have no control over what that application does
    3) conclusion: what you want is not possible using the web
    Other than that, asking for code without showing that you put some effort into the problem yourself is a sure way of getting flamed. You should know that by now, since you registered more than 2 years ago...

  • Problem with "Saved with Id" in Reports

    Hi Group,
    I am having problem with "Saved with id" functionality.
    1.) I created a Query in sq01 as "query1".
    2.) Copied the source code of this query into a z program
    ztest_query.
    3.) Now executed the report "ztest_query" in background with "Saved with Id" checkbox checked and id as "1234".
    4.) Now where/how can I search for this id "1234" to retrieve my list.
    5.) Normally if I dont change the report name and use the program aq*query1 which is self generated one, this works and I am able to retrieve the saved list from Transaction
    SQ01.
    Please let me know how this can be achieved.
    Regards
    Ankur Bhandari

    Ankur,
    Did you find a solution for this problem. Not many seem to be using this "Save list to id" functionality.
    Thanks
    Vyas

  • Problem while saving an object under a dev class

    hi all,
            Here is a problem while saving an object under a development class.... I created a Z program (ZSORDER)  through SE38 and while i was saving that Z program under a development class called SALES it shows an error message like  <b>" customer object program ZSORDER can't be assigned to the package SALES"</b>..... can any one can explain what is the problem....

    hi,
    you should have created your package starting with the letters "Y" or "Z".
    you have created it with the letter "s". SALES.
    's' is reserved to be used by SAP.
    so create the package  with the letters 'y' or 'z' like 'ysales' and you wont be getting that problem.
    try it.
    warm regards,
    Hari Kiran

  • Problems with saving decimal data

    Hello!
    I was faced with problem during saving decimal data via Excel input schedules. We use BPC 7.0 MS, SQL Server 2008.
    One of the main customer demands is using decimal comma (",") due to Russian regional settings and standards. We've switched server regional options and one of the client machine's regional options into Russian, all integer data is sent to SQL correctly but during saving decimal data we got error - Type mismatch.
    Do you mind how to solve this issue? Or it is possible only using English standarts?
    Thanks for your help.
    Regards, Maksim.

    Hi Maksim,
    To understand if you have set correct regional settings for you SAP BPC server you have to check the follow keys:
    HKEY_USERS\.Default\Control Panel \ International
    HKEY_USERS\S-1-5-18\Control Panel \ International
    HKEY_USERS\S-1-5-19\Control Panel \ International
    HKEY_USERS\S-1-5-20\Control Panel \ International
    HKEY_USERS\S-1-5-21\Control Panel \ International
    HKEY_USERS\S-1-5-21.....\Control Panel \ International
    should have all the keys for English US.
    Kind Regards
    Sorin Radulescu

  • Problems with saving a file

    Hello,
    Im having problems with saving files on my computer, from Mail and Safari. I have 900gb free diskspace, but i simply cant save anyhow, it says my disk is full.
    Have i accidentally locked something up?
    Regards,
    Niclas

    Run disk utility on your hard drive to repair your permissions.  http://support.apple.com/kb/HT1452

Maybe you are looking for

  • PQAH- can't see SAVE button

    Hi friends, I have a test user into 2 environments, Prod and QA. Into prod, using PQAH t-code test user can see SAVE, NEW and OPEN button to use query. But into QA environment, user can't see any of these buttons. User has same roles into both enviro

  • Error message when trying to burn CD's

    I am getting "Unknown Error # 4450" repeatedly when I try to burn a CD from my i tunes library. Anyone know how to fix this?

  • Can't figure out how to open program

    I have downloaded the 30 day trial version and it is done installing, but i can not find a program or anything so i can use it.

  • Faulty hard drive? Memory analysis

    Hey Been trying to figure out whether or not my new MBP's hard drive is faulty. It's a 13" 2,56GHz (Core2Duo) with 4 GB RAM Can you help me find out by "analyzing" these numbers? I did this clean install and got these numbers - after the clean instal

  • Exporting image to burn in another program?

    Hello all and Merry Christmas... I have been told that it is possible to export a project as an image in order to burn it in a different program, for example to be able to change the recording speed if needed... Could someone tell me how to do it ple