Receiving it as a byte array via socket

Yes, I could know the data end as read() returning -1 and the total byte-count value is in my hand then. But, however, if the byte-count value is N, I want those bytes in a single byte array of size N. What could be the standard, quickest and smartest way of getting the byte array on a socket peer?

hiwa wrote:
The readFully() method takes a byte array as an argument. The size of the array can't be decided as the total data size when we begin reading. We don't know it yet then.
My method would be:
LOOP(read -> out to a ByteArrayOutputStream) -> call ByteArrayOutputStream.toByteArray()
However, if there is/are more smarter ones ...What problem are you actually trying to solve here?
Here's a possible "solution" for you.
Use a buffer. Then read the buffer and append the contents to a larger buffer. With code like this.
private byte[] mergeBuffers(byte[] a, byte b[]){
  byte[] newBuffer = new byte[a.length+b.length];
  System.arraycopy(a,0,newBuffer,0,a.length);
  System.arraycopy(b,0,newBuffer,a.length,b.length);
  return newBuffer;
}so during the read loop as the buffer fills up add the results of the current buffer to your "super"-buffer or whatever you want that has all the data.
And then when you have finished reading trim the byte array to fit.

Similar Messages

  • Byte array convert to image works fine for a peiod of time, Then error

    Hi all
    I'm on a program of reading incoming image set which comes as byte arrays through socket and convert them back to images using the method.
    javax.microedition.lcdui.Image.createImage();This works perfect for some time.
    But after 1 minute of running it gives an error
    java.lang.OutOfMemoryError: Java heap space
            at java.awt.image.BufferedImage.getRGB(Unknown Source)
            at com.sun.kvem.midp.GraphicsBridge.loadImage(Unknown Source)
            at com.sun.kvem.midp.GraphicsBridge.createImageFromData(Unknown Source)
            at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at com.sun.kvem.sublime.MethodExecution.process(Unknown Source)
            at com.sun.kvem.sublime.SublimeExecutor.processRequest(Unknown Source)
            at com.sun.kvem.sublime.SublimeExecutor.run(Unknown Source)My J2ME client code
    public class ChangeImage extends Thread
        private SocketConnection sock = null;
        private Image img = null;
        private CanvasKey canvas = null;
        private InputStream in = null;
        public ChangeImage(SocketConnection sock, Canvas canvas) throws IOException
            this.sock = sock;
            this.canvas = (CanvasKey) canvas;
            in = sock.openInputStream();
        public void run()
            super.run();
            short length;
            while (true)
                DataInputStream din = null;
                try
                    din = new DataInputStream(in);
                    length = din.readShort();     // to determine next data packet size
                    byte[] arr = new byte[length];  // next data packet store here
                    din.readFully(arr);  //read image
                    img = Image.createImage(arr, 0, arr.length);
                    canvas.setImage(img);
                    ChangeImage.sleep(50);
                catch (Exception ex)
                    ex.printStackTrace();
    }When I comment following line no error prints.
    img = Image.createImage(arr, 0, arr.length);So the problem is not with socket program.
    What is this problem? Think old image isn't being flushed!!! in the method javax.microedition.lcdui.Image.createImage();Please help me.

    Forgot to Mention i'm using Windows 8.1 - 32 GB Ram - i7-3970x - 2 SSd's in raid 0 for C Drive/ Storage drive is three ( 2 tb HDD in a raid 0 ) / Pictures Folder defaults to the Storage Drive not the Application drive .

  • Receiving Image via socket and creating via byte[]...

    Hi Folks...
    I�m trying to send a WebCam SnapShot to my Midlet running in a PDA via socket..
    The method used to send the Image is:
    BufferedImage img = toBufferedImage( getScreenShot( getFrameBuffer() ) );
              byte[] buf = convertImage( toBufferedImage( img ) );
              BASE64Encoder enc64 = new BASE64Encoder();
              enc64.encode(buf);
              try {
                   out.writeUTF("IMAGEM");
                   out.writeInt( buf.length );
                   out.write( buf );
              } catch (IOException e) {
                   e.printStackTrace();
              }So this code get a snapShot from the webCam and returns a BufferedImage. This BufferedImage is converted to a byte[], and later this byte[] is encoded in Base64 format with BASE64Encoder.
    In the next step the buffer is sent to the client, the server send the message "IMAGEM", in the sequence the size off the byte[] and then the byte[].
    The code that receive the Image byte[]...
    private void receiveImageAction(){
              byte[] buf;
              try {
                   buf = new byte[ in.readInt() ];
                   in.read(buf);
                   Image img = Image.createImage( buf, 0 , buf.length );
                   viewForm.setMsg("Image created");
                   viewForm.setImageView(img);
              } catch (IOException e) {
                   viewForm.setMsg( "" + e.toString() );
              }catch(Exception e){
                   viewForm.setMsg( "" + e.toString() );
         }When the connection manager receives a message "IMAGEM" the function receiveImageAction is called.
    It receives the size off the byte[] and then receive the array.
    When I try to create the image using Image.createImage( byte[], int, int ) the exception IllegalArgumentException is throwed...
    The exception doesnt have a message...
    What is wrong ?
    Is the format off my image sent ?
    Is my buffer been encoded correctly by the BASE64Encoder class ?

    Will u try with replacing this line
    Image img = Image.createImage( buf, 0 , buf.length );with this line
    Image img = Image.createImage( buf, 0 , buf.length-1 );

  • How to pass and receive byte[] via socket

    Hi All,
    How can I pass a byte[] from client socket to the server socket.
    Also how to receive that bye[] at the server socket.
    Thanks and best Regards,
    - Lasith.

    Hi All,
    Thanks for replying my topic, but still I need some help regarding this.
    My requirement is to have client and server socket programs with following functions (this is bit related to cryptography as well :)).
    First I generate public and private keys for server and in the client side generating a random number and encrypt it with servers public key and sends to server.
    Please refer following code segment.
    SecureRandom random = new SecureRandom();
              long challange = random.nextLong();     
              Cipher cipher = Cipher.getInstance("RSA");
              cipher.init(Cipher.ENCRYPT_MODE, key, new SecureRandom());
                 byte[] cipherText = cipher.doFinal(new Long(challange).toString().getBytes());
                 String cipherTextToServer = cipherText.toString();Then I am passing this string to server socket as follows,
    if(cipherTextToServer !=null)
                   out.println(cipherTextToServer );The server should take this text and decrypt it as follows.
         PrintWriter out = new PrintWriter(client.getOutputStream(),true);
              BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
    while((fromClinet  = in.readLine()) != null){
                   System.out.println("Server -> "+fromClinet);
                   System.out.println("Server -> "+*getDecriptedMassage*(fromClinet,prvKey));
                            out.println(Utility.getDecriptedMassage(massage,prvKey));
         public String getDecriptedMassage(String massage,Key key) throws Exception{
              Cipher cipher = Cipher.getInstance("RSA");
            cipher.init(Cipher.DECRYPT_MODE, key);
            byte[] plainText = cipher.doFinal(massage.getBytes());
            System.out.println("plain : " +new String(plainText));
             return plainText.toString();
         }When running the program I am getting following error.
    Exception in thread "main" java.net.SocketException: Connection reset
         at java.net.SocketInputStream.read(Unknown Source)
         at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
         at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
         at sun.nio.cs.StreamDecoder.read(Unknown Source)
         at java.io.InputStreamReader.read(Unknown Source)
         at java.io.BufferedReader.fill(Unknown Source)
         at java.io.BufferedReader.readLine(Unknown Source)
         at java.io.BufferedReader.readLine(Unknown Source)
         at Client.main(Client.java:46)
    As my investigation if I can remove following code segments then program is working fine.
    System.out.println("Server -> "+*getDecriptedMassage*(fromClinet,prvKey));
    out.println(Utility.getDecriptedMassage(massage,prvKey));So this should be a error when decrypting message. If I am further explaining this the sending encrypted message with client is not same as getting decrypted message on server. Because of this program is giving the error.

  • Why is byte array not received in full?

    Hello,
    I have a pair of client/server programs. The client program sends in user and organization names, and the servlet (after some verification against the database) returns back an expiry date, and an encoded signature in a byte array.
    It works perfectly when a query string is given via a web browser; it also works perfectly with the servlet on a local Tomcat server. However, when the servlet is on a real remote machine, the byte array being sent back is truncated -- only the expiry date part is received. The signature is missing.
    I'm not sure why...
    The snippet of code in the servlet looks like this:
    //HttpServletResponse out from doGet()
    out.getOutputStream().write(returnArray);
    out.getOutputStream().flush();
    out.getOutputStream().close();
    the client part looks like:
    // url connects to the servlet
    URLConnection connect = url.openConnection();
    //Get the data it sends back
    InputStream inStream = connect.getInputStream();
    //Get the contents of the input stream, and convert to a string
    byte[] b = new byte[512];
    int numRead = inStream.read(b);
    By the way, when testing on local Tomcat, it works only if the outputStream is not flush()'ed or close()'ed. i.e. with those two statements, the byte array gets truncated regardless of where the servlet is located.
    It seems to be bugging me forever ... =(
    Thanks for your help!
    Tina

    I dont know if this makes sense but this mite be the problem
    Your client opens a URConnection con1 ... sends data to the servlet. Servlet does some processing sends data to the client. Now are u creating another URLConnection object to receive the data on the client?
    Though my analysis seems wrong coz ur getting one part of the data. Buf if you are using two different connection objects for sending and receiving, I think you are doing wrong.

  • Sending a Byte array through a socket

    Can someone please tell me how i can send a Byte array from a client to a sever using sockets?
    Thanks
    Mark

    This tutorial should do the trick:
    http://java.sun.com/docs/books/tutorial/networking/sockets/index.html

  • Need to send and receive larger byte array

    I have a small WCF service, self hosted in a console app. On the same computer I have a client application. Both are running in the debugger in VS2008. The proxy code and the config file were generatred from the running service using svcutil.
    In one of the service calls, the service reads a pdf file and sends the contents as a byte array. The client receives the byte array, saves it as a pdf file, and displays it.
    Everything is fine for all other kinds of calls, and this one works fine also as long as the file is small (say 14K). But if the file is larger (say 84K), the client crashes (VHOST has stopped working).
    Is there some kind of setting that will allow me to send and receive larger byte arrays (> 100 K)?
    Thanks,
    Jon Jacobs
    In transmission, subatomic particles managed by professionals.
    No innocent electrons were harmed.

    Hi Jon,
    You'll want something like this to increase the message size quotas:
    <bindings>
    <basicHttpBinding>
    <binding name="basicHttp" allowCookies="true"
    maxReceivedMessageSize="20000000"
    maxBufferSize="20000000"
    maxBufferPoolSize="20000000">
    <readerQuotas maxDepth="32"
    maxArrayLength="200000000"
    maxStringContentLength="200000000"/>
    </binding>
    </basicHttpBinding>
    </bindings>
    The justification for the values is simple, they are sufficiently large to accommodate most messages. You can tune that number to fit your needs. The low default value is basically there to prevent DOS type attacks. Making it 20000000 would allow for a distributed
    DOS attack to be effective, the default size of 64k would require a very large number of clients to overpower most servers these days.
    If you're still getting this error message while using the WCF Test Client, it's because the client has a separate MaxBufferSize setting.
    To correct the issue:
    Right-Click on the Config File node at the bottom of the tree
    Select Edit with SvcConfigEditor
    A list of editable settings will appear, including MaxBufferSize.
    Note: Auto-generated proxy clients also set MaxBufferSize to 65536 by default.
    Let me know if this helped.
    Regards,
    Raghu

  • Socket connection, byte array

    I've got a problem with byte array. It needs to be initialized f.e.
    byte[] data = new byte[100];However, I'm gonna read input stream to that array
    is.read(data);and input stream might be longer than expected f.e. 1000 bytes.
    What can I do to predict the length of byte[] or avoid NullPointerException
    public void connect() throws IOException {SocketConnection client = (SocketConnection) Connector.open("socket://" + hostname + ":" + port);
    client.setSocketOption(client.DELAY, 0);
    client.setSocketOption(client.KEEPALIVE, 0);
    InputStream is = client.openInputStream();
    OutputStream os = client.openOutputStream();
    os.write("some string".getBytes());
    int c = 0;
    byte[] data = new byte[100];
    is.read(data);
    while((c = is.read()) != -1) {
    System.out.print((char)c);
    is.close();
    os.close();
    client.close();
    }

    excellent thanks
    for other users:
        public byte[] getBytes() throws IOException {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            SocketConnection client = (SocketConnection) Connector.open("socket://" + hostname + ":" + port);
            client.setSocketOption(client.DELAY, 0);
            client.setSocketOption(client.KEEPALIVE, 0);
            InputStream is = client.openInputStream();
            OutputStream os = client.openOutputStream();
            os.write("some string".getBytes());
            int c = 0;
            while((c = is.read()) != -1) {
                baos.write(c);
            is.close();
            os.close();
            client.close();
            return baos.toByteArray();
        }

  • How to send byte array and String values to servlet from Swing application

    Hi all,
    I am new to swing, servlet, and socket connection.
    I have swing application to draw images and some input data. I dont know to send to server.
    byte[] buf = baos.toByteArray();
    URL servletURL = new URL("http://10.70.70.1:8080/servlet/SaveImage)
    URLConnection conn = servletURL.openConnection();
    conn.setDoOutput(true);
    BufferedWriter out = new BufferedWriter( new OutputStreamWriter( conn.getOutputStream() ) );
    out.write(buf&a=aaaa&b=bbbbb);
    out.flush();
    out.close();
    can I do like this. Strings are received in server side perfect. but i cant get byte array data. Please help me.
    Thanks in advance.

    <img src="myservlet">
    In your myservlet:
    response.setContentType("image/jpeg");
    then write your image date via ImageIO that uses response output stream.

  • How to add 16 bit message sequential number to the byte array

    hi
    iam trying to implement socket programming over UDP. Iam writing for the server side now.I need to send an image file from server to a client via a gateway so basically ive to do hand-shaking with the gateway first and then ive to send image data in a sequence of small messages with a payload of 1 KB.The data message should also include a header of 16 bit sequential number and a bit to indicate end of file.
    Iam able to complete registration process(Iam not sure yet).I dnt know how to include sequential number and a bit to indicate end of file.
    I would like to have your valuable ideas about how to proceed further
    package udp;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class Sender  {
        protected BufferedReader in = null;
        protected FileInputStream image=null;
        protected static boolean end_of_file=true;
    /** pass arguments hostname,port,filename
    * @param args
    * @throws IOException
       public static void main(String[] args) throws IOException{
            DatagramSocket socket = new DatagramSocket(Integer.parseInt(args[1]));
            boolean more_messages = true;
              String str1=null;
                * gateway registration
                try{
                     //send string to emulator
                    String str="%%%GatewayRegistration SENDER test delay 10 drop 0 dupl 0 bandwidth 1000000";
                    byte[] buff=str.getBytes();
                    InetAddress emulator_address = InetAddress.getByName(args[0]);
                    DatagramPacket packet = new DatagramPacket(buff, buff.length,emulator_address,Integer.parseInt(args[0]));
                    socket.send(packet);
                        // figure out response
                    byte[] buf = new byte[1024];
                    DatagramPacket recpack=new DatagramPacket(buf,buf.length);
                    socket.receive(recpack);
                   // socket.setSoTimeout(10000);
                    String str2=str1.valueOf(new String(recpack.getData()));
                    if(socket.equals(null))
                         System.out.println("no acknowledgement from the emulator");
                        socket.close();
                    else if(str2=="%%%GatewayConfirmation")
                    //     String str1=null;
                         System.out.println("rec message"+str2);
                    else
                         System.out.println("not a valid message from emulator");
                         socket.close();
                catch (IOException e) {
                    e.printStackTrace();
                      end_of_file = false;
         /**create a packet with a payload of 1     KB and header of 16 bit sequential number and a bit to indicate end of file
      while(end_of_file!=false)
          String ack="y";
          String seqnum=
           File file = new File(args[2]);                               
                    InputStream is = new FileInputStream(file);                 
            socket.close();
      private byte[] byteArray(InputStream in) throws IOException {
             byte[] readBytes = new byte[1024]; // make a byte array with a length equal to the number of bytes in the stream
          try{
             in.read(readBytes);  // dump all the bytes in the stream into the array
            catch(IOException e)
                 e.printStackTrace();
            return readBytes;
      

    HI Rolf.k.
    Thank you for the small program it was helpfull.
    You got right about that proberly there  will be conflict with some spurios data, I can already detect that when writing the data to a spreadsheet file.
    I writes the data in such a way, that in each line there will be a date, a timestamp, a tab and a timestamp at the end. That means two columns.
    When i set given samplerate up, that controls the rate of the data outflow from the device, (1,56 Hz - 200 Hz),   the data file that i write to , looks unorderet.
     i get more than one timestamp and severel datavalues in every line and so on down the spreadsheet file.
    Now the question is: Could it be that the function that writes the data to the file,  can't handle the speed of the dataflow in such a way that the time stamp cant follow with the data flowspeed. so i'm trying to set the timestamp to be  with fractions of the seconds by adding the unit (<digit>) in the timestamp icon but its not working. Meaby when i take the fractions off a second within the timestamp i can get every timestamp with its right data value. Am i in deeb water or what do You mean!??
    AAttached Pics part of program and a logfile over data written to file
    regards
    Zamzam
    HFZ
    Attachments:
    DataFlowWR.JPG ‏159 KB
    Datalogfile.JPG ‏386 KB

  • Trying to send multiple types in a byte array -- questions?

    Hi,
    I have a question which I would really appreciate any help on.
    I am trying to send a byte array, that contains multiple types using a UDP app. and then receive it on the other end.
    So far I have been able to do this using the following code. Please note that I create a new String, Float or Double object to be able to correctly send and receive. Here is the code:
    //this is on the client side...
    String mymessage ="Here is your stuff from your client" ;
    int nbr = 22; Double nbr2 = new Double(1232.11223);
    Float nbr3 = new Float(8098098.809808);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(mymessage);
    oos.writeInt(nbr);
    oos.writeObject(nbr2);
    oos.writeObject(nbr3);
    oos.close();
    byte[] buffer = baos.toByteArray();
    socket.send(packet);
    //this is on the server side...
    byte [] buffer = new byte [5000];
    String mymessage = null; int nbr = 0; Double nbr2 = null;
    Float nbr3 = null;
    mymessage = (String)ois.readObject();
    nbr = ois.readInt();
    nbr2 = (Double) ois.readObject();
    nbr3 = (Float) ois.readObject();
    My main question here is that I have to create a new Float and Double object to be able to send and receive this byte array correctly. However, I would like to be able to have to only create 1object, stuff it with the String, int, Float and Double, send it and then correctly receive it on the other end.
    So I tried creating another class, and then creating an obj of this class and stuffing it with the 4 types:
    public class O_struct{
    //the indiv. objects to be sent...
    public String mymessage; public int nbr; public Double nbr2;
    public Float nbr3;
    //construct...
    public O_struct(String mymessage_c, int nbr_c, double nbr2_c, float nbr3_c){
    my_message = my_message_c;
    nbr = nbr_c;
    nbr2 = new Double(nbr2_c);
    nbr3 = new Float(nbr3_c);
    Then in main, using this new class:
    in main():
    O_struct some_obj_client = new O_struct("Here is your stuff from your client", 22, 1232.1234, 890980980.798);
    oos.writeObject(some_obj_client);
    oos.close();
    send code....according to UDP
    However on the receiving side, I am not sure how to be able to correctly retrieve the 4 types. Before I was explicitely creating those objects for sending, then I was casting them again on the receiving side to retrieve then and it does work.
    But if I create a O_struct object and cast it as I did before with the indiv objects on the receiving end, I can't get the correct retrievals.
    My code, on the server side:
    O_struct some_obj_server = new O_struct(null, null, null. null);
    some_obj_server = (O_struct)ois.readObject();
    My main goal is to be able to send 4 types in a byte array, but the way I have written this code, I have to create a Float and Double obj to be able to send and receive correctly. I would rather not have to directly create these objects, but instead be able to stuff all 4 types into a byte array and then send it and correctly be able to retrieve all the info on the receiver's side.
    I might be making this more complicated than needed, but this was the only way I could figure out how to do this and any help will be greatly appreciated.
    If there an easier way to do I certainly will appreciate that advise as well.
    Thanks.

    public class O_struct implements Serializable {
    // writing
    ObjectOutputStream oos = ...;
    O_struct struct = ...;
    oos.writeObject(struct);
    // reading
    ObjectInputStream ois = ...;
    O_struct struct = (O_struct)ois.readObject();
    I will be sending 1000s of these byte arrays, and I'm sure having to create a new Double or Float on both ends will hinder this.
    I am worried that having to create new objs every time it is sending a byte array will affect my application.
    That's the wrong way to approach this. You're talking about adding complexity to your code and fuglifying it because you think it might improve performance. But you don't know if it will, or by how much, or even if it needs to be improved.
    Personally, I'd guess that the I/O will have a much bigger affect on performance than object creation (which, contrary to popular belief, is generally quite fast now: http://www-128.ibm.com/developerworks/java/library/j-jtp01274.html)
    If you think object creation is going to be a problem, then before you go and cock up your real code to work around it, create some tests that measure how fast it is one way vs. the other. Then only use the cock-up if the normal, easier to write and maintain way is too slow AND the cock-up is significantly faster.

  • How to load and display a byte array (jpeg) image file dynamically in Flex?

    My web service client (servlet) received a binary jpeg data from an Image Server. The Flex application invokes the
    servlet via HttpService and receives the binary jpeg data as byte array.  How could it be displayed dynamically
    without writing the byte array to a jpeg file?  Please help (some sample code is very much appreciated).

    JPEGEncoder is only useful for converting BitmapData to ByteArray, not the other way around.
    By the way JPEGEncoder and PNGEncoder are part of the Flex SDK now, so no need to use AS3Lib (alltough it's a good library to have around).
    To display/use a ByteArray as image, use a Loader instance with the loadBytes method.
        Loader.loadBytes(bytes:ByteArray, context:LoaderContext = null);
    Listen for the complete event on the Loader.contentLoaderInfo and get the BitmapData in the event handler.
    private function loadJpeg():void {
        var loader:Loader = new Loader();
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderCompleteHandler);
        //jpgBA is the ByteArray loaded from webservice
        loader.loadBytes(jpgBA);
    private function loaderCompleteHandler(evt:Event):void {
        var t:LoaderInfo = evt.currentTarget as LoaderInfo;
        // display the jpeg in an Image component
        img.source = t.content;
    <mx:Image id="img" scaleContent="false" />

  • How to find the last element of a byte array

    Dear all,
    I have a byte array with a max lenght of 1024*50 bytes. In that array I store the bytes read from a file. How can I find where the array ends (i.e. which is the last valid element of the byte array)?
    Thank you for your help.
    Best Regards,
    JIM

    I want to send files over TCP connection using BufferedOutputStreams and BufferedInputStreams. The first side (e.g. the client) sends a file (e.g mp3 file or jpeg image) to the server using the code
      public void sendFile(Socket s, String FileName) throws Exception
              BufferedOutputStream out = new BufferedOutputStream(s.getOutputStream());  
              BufferedInputStream in = new BufferedInputStream(new FileInputStream(FileName));
              int len = 0;
              while ( (len = in.read(buffer)) > 0) {
                out.write(buffer, 0, len);
              in.close();
              out.flush();
            }(The client does not close the BufferedOutputStream out because other files will be sent afterwards)
    Then, the server receives the file using the code:
            public void receiveFile(Socket s, String FileName) throws Exception
              OutputStream out = new BufferedOutputStream(new FileOutputStream(FileName)); 
              InputStream in = new BufferedInputStream(s.getInputStream());
              int len = 0;
              while ( (len = in.read(buffer)) > 0) {
                out.write(buffer, 0, len);
                break;
              out.flush();
              out.close();
            }(likewise the InputStream in is not closed for the same reasons).
    In order the server to receive the file and stop reading the BufferedInputStream, I will have to make some modifications to this part of the code,
    while ( (len = in.read(buffer)) > 0)so as to know when the whole file has been received.
    Thus, even if I send the length of each file, I will not be able to read it. Could you please recommend me a solution?

  • I need to send a message via socket from a C program to a Java program

    Hi,
    I need to send a message via socket from a C program to a Java program. The message has three data: a long, an integer and a string.
    How can I put those three fields in a array of bytes in C? How can I extract those same three fields from an array of bytes in java?
    Thanks a lot!

    A few options:
    JNI
    Corba
    Using sockets directly
    take your pick.

  • UnmarshalException for large byte array :: Weblogic 8.1 SP2

    Hi,
    1) We have a application running on Weblogic 8.1SP2.
    2) Our scenario consist of Client code which reads a input file via Stream and converts it to a byte array before sending it to the Server.
    When the server side code calls the Remote Bean (with byte array as an argument) it throws this exception :
    "java.rmi.UnmarshalException: Software caused connection abort: socket write error"
    Intermittently also got this error :: "weblogic.rjvm.PeerGoneException: ; nested exception is: java.io.EOFException"
    3) This scenario works absolutely fine if the said Input File is of a smaller size.
    4) I have also set the following params in config.xml <server .../> tag, but all in vain:
         CompleteMessageTimeout="480" also tried with "0"
         MaxMessageSize="2000000000"
         NativeIOEnabled="true"
    Also tried with :
         MaxHTTPMessageSize="2000000000" & MaxT3MessageSize="2000000000"
    Below is the exception trace:
    java.rmi.UnmarshalException: Software caused connection abort: socket write error; nested exception is: java.net.SocketException: Software caused connection abort: socket write error
    java.rmi.UnmarshalException: Software caused connection abort: socket write error; nested exception is: java.net.SocketException: Software caused connection abort: socket write error at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:297)
         at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:244)
    Caused by: java.net.SocketException: Software caused connection abort: socket write error
         at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108)
         at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:284)
         ... 6 more
    Caused by: java.net.SocketException: Software caused connection abort: socket write error
         at java.net.SocketOutputStream.socketWrite0(Native Method)
         at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
         at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
         at weblogic.socket.SocketMuxer.write(SocketMuxer.java:721)
         at weblogic.rjvm.t3.T3JVMConnection.sendMsg(T3JVMConnection.java:723)
         at weblogic.rjvm.MsgAbbrevJVMConnection.sendOutMsg(MsgAbbrevJVMConnection.java:276)
         at weblogic.rjvm.MsgAbbrevJVMConnection.sendMsg(MsgAbbrevJVMConnection.java:164)
         at weblogic.rjvm.ConnectionManager.sendMsg(ConnectionManager.java:549)
         at weblogic.rjvm.RJVMImpl.send(RJVMImpl.java:722)
         at weblogic.rjvm.MsgAbbrevOutputStream.flushAndSendRaw(MsgAbbrevOutputStream.java:292)
         at weblogic.rjvm.MsgAbbrevOutputStream.flushAndSend(MsgAbbrevOutputStream.java:300)
         at weblogic.rjvm.MsgAbbrevOutputStream.sendRecv(MsgAbbrevOutputStream.java:322)
         at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:103)
         ... 7 more
    Any thoughts would be helpful?
    Thanks,
    Khyati

    Hi,
    1) We have a application running on Weblogic 8.1SP2.
    2) Our scenario consist of Client code which reads a input file via Stream and converts it to a byte array before sending it to the Server.
    When the server side code calls the Remote Bean (with byte array as an argument) it throws this exception :
    "java.rmi.UnmarshalException: Software caused connection abort: socket write error"
    Intermittently also got this error :: "weblogic.rjvm.PeerGoneException: ; nested exception is: java.io.EOFException"
    3) This scenario works absolutely fine if the said Input File is of a smaller size.
    4) I have also set the following params in config.xml <server .../> tag, but all in vain:
         CompleteMessageTimeout="480" also tried with "0"
         MaxMessageSize="2000000000"
         NativeIOEnabled="true"
    Also tried with :
         MaxHTTPMessageSize="2000000000" & MaxT3MessageSize="2000000000"
    Below is the exception trace:
    java.rmi.UnmarshalException: Software caused connection abort: socket write error; nested exception is: java.net.SocketException: Software caused connection abort: socket write error
    java.rmi.UnmarshalException: Software caused connection abort: socket write error; nested exception is: java.net.SocketException: Software caused connection abort: socket write error at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:297)
         at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:244)
    Caused by: java.net.SocketException: Software caused connection abort: socket write error
         at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108)
         at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:284)
         ... 6 more
    Caused by: java.net.SocketException: Software caused connection abort: socket write error
         at java.net.SocketOutputStream.socketWrite0(Native Method)
         at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
         at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
         at weblogic.socket.SocketMuxer.write(SocketMuxer.java:721)
         at weblogic.rjvm.t3.T3JVMConnection.sendMsg(T3JVMConnection.java:723)
         at weblogic.rjvm.MsgAbbrevJVMConnection.sendOutMsg(MsgAbbrevJVMConnection.java:276)
         at weblogic.rjvm.MsgAbbrevJVMConnection.sendMsg(MsgAbbrevJVMConnection.java:164)
         at weblogic.rjvm.ConnectionManager.sendMsg(ConnectionManager.java:549)
         at weblogic.rjvm.RJVMImpl.send(RJVMImpl.java:722)
         at weblogic.rjvm.MsgAbbrevOutputStream.flushAndSendRaw(MsgAbbrevOutputStream.java:292)
         at weblogic.rjvm.MsgAbbrevOutputStream.flushAndSend(MsgAbbrevOutputStream.java:300)
         at weblogic.rjvm.MsgAbbrevOutputStream.sendRecv(MsgAbbrevOutputStream.java:322)
         at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:103)
         ... 7 more
    Any thoughts would be helpful?
    Thanks,
    Khyati

Maybe you are looking for

  • Custom field to add number of packages shipped along with Delivery

    Hi Sap Experts, We have scenario, we have created sales order with quantity 1(Like soft copy or hard copy of CD). Now we want to create delivery with sales order and quantity is 1(Copy from sales order). Our requirement is some time we have to send a

  • Sun-Java-System-SMTP-Warning

    Customers using our company's products have been finding the following error message when sending messages with image attachments from our devices: "Sun-Java-System-SMTP-Warning: Lines longer than SMTP allows found and truncated" RFC 2045 - Multipurp

  • IPhoto '8, Some photos from Original Folder no longer showing

    Hello All: I am working on my sisters' iMac and she has the following problem with iPhoto. Somehow (we have deduced that her husband tried to help "clean-up" the computer), there are 7 months worth of pictures no longer showing in iPhoto.  Here is wh

  • I think my hard drive may be faulty

    iI recently purchased a second hand iMac - 27" mid 2010. Things have been going well, I 'defaulted' the machine, re-installed OS X from the original DVD and purchased/upgraded to the latest version (OS X Mountain Lion 10.8.5). After 'tinkering' with

  • Clear session state for related application/page

    I have an application item I want to clear and I am not sure what is the correct session state process type to select I am reading about the different state process but I am not sure. I thought it was Clear Cache for Items (ITEM,ITEM,ITEM) but this i