Files sending over socket

Here is my server-code:
  for (int i=0; i<countGamesToDownload; i++)
                             out.write(gamesToDownload.get(i) + ".zip\n");
                             out.flush();
                             filename=System.getProperty("user.dir")+"\\"+ gamesToDownload.get(i)+".zip";
                             System.out.println("Filename: " + filename);
                             bin = new BufferedInputStream(new FileInputStream(new File(filename)));
                             int len = 0;
                              while ((len = bin.read(buffer)) > 0) {
                                   bout.write(buffer, 0, len);
                                   System.out.println("#");     
                              bin.close();
                              bout.flush();
                         }That's my client-code:
for (GameInfo gi : gamesToDownloadVec)
                               filename= "C:\\Temp\\" + in.readLine();
                               System.out.println ("Filename: " + filename);
                               bout = new BufferedOutputStream(new FileOutputStream(new File(filename)));
                               int bytesRead = 0;
                               while((bytesRead =bin.read(buffer))>0)
                                    bout.write(buffer, 0, bytesRead);
                                    System.out.println("#");
                               bout.flush();
                               bout.close();
                              //new Unzip(new File(filename));
                         }If I only send one game everything is fine...
but if i send more than i get as second filename: C:\Temp\null
If i am debugging the server, i get on the server-side:
file:\C:\Dokumente und Einstellungen\Edith\Eigene Dateien\java\eclipse-projekte\GameDownloadServer\GameList.xml is well-formed.
Anzahl neuer Spiele: 4
Filename: C:\Dokumente und Einstellungen\Edith\Eigene Dateien\java\eclipse-projekte\GameDownloadServer\Game1.zip
Filename: C:\Dokumente und Einstellungen\Edith\Eigene Dateien\java\eclipse-projekte\GameDownloadServer\Game2.zip
client-side:
Filename: C:\Temp\Game1.zip
Filename: C:\Temp\null
Only one # is ok, because the file is only ablout 1800 kb and my buffer-size is 1024*50...
I don't know where the problem is. it would be very great if anyone can help me...
Greatings
schaefli

in.readLine() has returned null in the client. Check the API to see what this means.

Similar Messages

  • Binary file transfert over socket : data corupted !

    Hi everyone,
    I am trying to transfert binary files over Socket (java.net) and I get corrupted data... I know the data I write in the Socket is ok and I wonder why I don't get it right at the end.
    Does anyone know about it ?

    Ok i have re-written it without the Packet class and it know works...
    I give my code in case someone would be interested.
    ENCODER :
    public class Encoder {
         // the file to send
         private File file;
          * Constructor of the Encoder class
          * @param path the path to the file to send
         public Encoder(String path){
              this.file = new File(path);
              this.encodeFile();
          * This method contains the connection an file tranfert code
         private void encodeFile(){
              try {
                   // opening file reading stream
                   FileInputStream fis = new FileInputStream(this.file);
                   // connection...
                   Socket sock = new Socket("127.0.0.1", 5698);
                   // opening an output stream
                   BufferedOutputStream bos = new BufferedOutputStream(sock.getOutputStream(), 1024);
                   // start time
                   long start = System.currentTimeMillis();
                   // setting up the buffer
                   byte[] buffer = new byte[1024];
                   /* ---- File Transfert Loop ---- */
                   // reading for the first time
                   int read = fis.read(buffer);
                   while (read > 0){
                        bos.write(buffer);
                        bos.flush();
                        read = fis.read(buffer);
                   /* ----End Of File Transfert ---- */
                   // end time
                   long end = System.currentTimeMillis();
                   // closing streams and connection
                   fis.close();
                   bos.close();
                   sock.close();
                   // display file transfert duration
                   System.out.println("Completed in :" + (end - start) + " ms !");
              } catch (IOException e) {
                   e.printStackTrace();
    DECODER :
    public class Decoder {
         private File destFile;
         public Decoder(String path){
              try {
                   // setting up destination file
                   this.destFile = new File(path);
                   // setting up file writting stream
                   FileOutputStream fos = new FileOutputStream(this.destFile);
                   // setting up connection server
                   ServerSocket serv = new ServerSocket(5698);
                   // accepting client connection request
                   Socket sock = serv.accept();
                   // setting up reading stream for the connection
                   BufferedInputStream bis = new BufferedInputStream(sock.getInputStream());
                   // setting up byte buffer
                   byte[] buffer = new byte[1024];
                   // first reading
                   int read = bis.read(buffer);
                   while (read != -1){
                        // writting buffer content into file
                        for (int i=0; i < read; i++){
                             fos.write(buffer);
                        // reading next bytes
                        read = bis.read(buffer);
                   //closing streams
                   fos.close();
                   bis.close();
              } catch (IOException e) {
                   e.printStackTrace();

  • Gzip only specific files extensions over sockets

    I am writing a socket webserver class that gzips only HTML files back to the browser (client). If the HTML file contains any images, I will have to send that over uncompressed. I am using GZIPOutputStream for my HTML objects, and a regular DataOutputStream for my other objects. None of my images show up correctly when I use DataOutputStream alone, but when I also gzip them, they show up fine. Also, all the images/html files show up fine if I exclude all the gzipping altogether. So it seems as though I have to either gzip them all ... or none at all.
    Is there a way to gzip only certain file extensions?
    Thanks!

    None of my images show up correctly when I use DataOutputStream alone, but when I also gzip them, they show up fine.Perhaps you aren't calling flush on the DataOutputStream (but the GZIP stream is) ?
    So it seems as though I have to either gzip them all ... or none at all. Probably not, I believe there is just an error in your code.
    Is there a way to gzip only certain file extensions?Sure,
    if (fileShouldBeGzipped(file.getName()))
      sendGzipFile(file);
    else
      sendFile(file);Of course, you must provide the fileShouldBeGzipped logic.
    Are you really implementing a webserver? That is, is it using http? If so, the standard practice (protocol) is that a client adds a header field which states what type of content encoding it can deal with in the response (i.e. gzipped content). If the server is capable, it replies with its own header stating the content is indeed gzipped along with the gzipped content. This way the client knows that it must decompress the data before doing something with it.

  • File transfer via socket problem (with source code)

    I have a problem with this simple client/server filetransfer program. When I run it, only half the file is transfered via the net? Can someone point out to me why this is happening?
    Client:
    import java.net.*;
    import java.io.*;
         public class Client {
         public static void main(String[] args) {
              // IPadressen til server
              String host = "127.0.0.1";
              int port = 4545;
              //Lager streams
              BufferedInputStream fileIn = null;
              BufferedOutputStream out = null;
              // Henter filen vi vil sende over sockets
              File file = new File("c:\\temp\\fileiwanttosend.jpg");
    // Sjekker om filen fins
              if (!file.exists()) {
              System.out.println("File doesn't exist");
              System.exit(0);
              try{
              // Lager ny InputStream
              fileIn = new BufferedInputStream(new FileInputStream(file));
              }catch(IOException eee) {System.out.println("Problem, kunne ikke lage fil"); }
              try{
              // Lager InetAddress
              InetAddress adressen = InetAddress.getByName(host);
              try{
              System.out.println("- Lager Socket..........");
              // �pner socket
              Socket s = new Socket(adressen, port);
              System.out.println("- Socket klar.........");
              // Setter outputstream til socket
              out = new BufferedOutputStream(s.getOutputStream());
              // Leser buffer inn i tabell
              byte[] buffer = new byte[1024];
              int numRead;
              while( (numRead = fileIn.read(buffer)) >= 0) {
              // Skriver bytes til OutputStream fra 0 til totalt antall bytes
              System.out.println("Copies "+fileIn.read(buffer)+" bytes");
              out.write(buffer, 0, numRead);
              // Flush - sender fil
              out.flush();
              // Lukker OutputStream
              out.close();
              // Lukker InputStrean
              fileIn.close();
              // Lukker Socket
              s.close();
              System.out.println("File is sent to: "+host);
              catch (IOException e) {
              }catch(UnknownHostException e) {
              System.err.println(e);
    Server:
    import java.net.*;
    import java.io.*;
    public class Server {
         public static void main(String[] args) {
    // Portnummer m� v�re det samme p� b�de klient og server
    int port = 4545;
         try{
              // Lager en ServerSocket
              ServerSocket server = new ServerSocket(port);
              // Lager to socketforbindelser
              Socket forbindelse1 = null;
              Socket forbindelse2 = null;
         while (true) {
         try{
              forbindelse1 = server.accept();
              System.out.println("Server accepts");
              BufferedInputStream inn = new BufferedInputStream(forbindelse1.getInputStream());
              BufferedOutputStream ut = new BufferedOutputStream(new FileOutputStream(new File("c:\\temp\\file.jpg")));
              byte[] buff = new byte[1024];
              int readMe;
              while( (readMe = inn.read(buff)) >= 0) {
              // Skriver filen til disken ut fra input stream
              ut.write(buff, 0, readMe);
              // Lukker ServerSocket
              forbindelse1.close();
              // Lukker InputStream
              inn.close();
              // flush - sender data ut p� nettet
              ut.flush();
              // Lukker OutputStream
              ut.close();
              System.out.println("File received");
              }catch(IOException e) {System.out.println("En feil har skjedd: " + e.getMessage());}
              finally {
                   try {
                   if (forbindelse1 != null) forbindelse1.close();
                   }catch(IOException e) {}
    }catch(IOException e) {
    System.err.println(e);
    }

    Hi!!
    The problem is at this line:
    System.out.println("Copies "+fileIn.read(buffer)+" bytes");
    Just comment out this line of code and see the difference. This line of code causes another "read" statement to be executed, but you are writing only the data read from the first read statement which causes approximately half the file to be send to the server.

  • Capturing Camera & Sending over TCP

    Hi friends,I work on network based project ,I am traing to capture webcam (audio + video) and send over network
    These code is working starts the webcam saves video and audio during given time(3000 (3 seconds) saves into file then stops the webcam.
    //formats[0] = new AudioFormat( AudioFormat.GSM);
    //formats[1] = new VideoFormat(VideoFormat.CINEPAK);
    //formats[1] = new VideoFormat(VideoFormat.H263);
    //FileTypeDescriptor outputType = new
    //FileTypeDescriptor( FileTypeDescriptor.QUICKTIME );
    formats[0] = new AudioFormat( AudioFormat.LINEAR);
    formats[1] = new VideoFormat(VideoFormat.RGB);
    FileTypeDescriptor outputType = new
    FileTypeDescriptor ( FileTypeDescriptor.MSVIDEO );
    try {
    p = Manager.createRealizedProcessor(
    new ProcessorModel( formats, outputType) );
    } catch( NoProcessorException e ) { System.out.println(e );
    } catch( CannotRealizeException e ) { System.out.println(e );
    } catch( IOException e ) { System.out.println (e );
    TrackControl track[] = p.getTrackControls();
    System.out.println("No. of tracks="+track.length);
    for (int i = 0; i < track.length; i++) {
    System.out.print("Track #"+i+": " +track.getFormat() + " \n" );
    } DataSource source = p.getDataOutput();
    String filename = "movies.mpg" ; // movie.avi
    String locator = "file://" + System.getProperty( "user.dir")
    System.getProperty( "file.separator") filename ;
    MediaLocator dest = new MediaLocator(locator);
    try{
    fileWriter = Manager.createDataSink( source, dest );
    } catch( NoDataSinkException e ) {
    System.out.println("The DataSink Exception tgv :" + e);
    } catch( SecurityException e ) { System.out.println(e); }
    fileWriter.addDataSinkListener( new DataSinkListener() {
    public void dataSinkUpdate( DataSinkEvent event) {
    if ( event instanceof EndOfStreamEvent ) {
    fileWriter.close();
    StreamWriterControl swc = ( StreamWriterControl)p.getControl(
    "javax.media.control.StreamWriterControl");
    if( swc != null) {
    swc.setStreamSizeLimit(1024 * 1024 );
    try{
    fileWriter.open();
    fileWriter.start();
    source.connect();
    source.start();
    p.start();
    } catch( IOException e ) { System.out.println(e);
    System.out.println( "File storage starts now \n ");
    try{
    Thread.sleep(3000);
    } catch( Exception e ) { System.out.println( "Error:" + e ); }
    System.out.println( "File storage stops now \n ");
    try{
    p.stop();
    p.close();
    fileWriter.close();
    source.disconnect();
    source.stop();
    } catch( IOException ioe ) { System.out.println( ioe ); }
    I works it is fine but I need to send it over network
    So what I need? I need to capture until I prefer to close webcam.
    I need to save the captured video and audio to the file every 1000 seconds then send it over network
    So I tried the code with timer and I add some code to send file over network.//formats[0] = new AudioFormat( AudioFormat.GSM);
    //formats[1] = new VideoFormat(VideoFormat.CINEPAK);
    //formats[1] = new VideoFormat(VideoFormat.H263);
    //FileTypeDescriptor outputType = new
    //FileTypeDescriptor( FileTypeDescriptor.QUICKTIME );
    formats[0] = new AudioFormat( AudioFormat.LINEAR);
    formats[1] = new VideoFormat(VideoFormat.RGB);
    FileTypeDescriptor outputType = new
    FileTypeDescriptor ( FileTypeDescriptor.MSVIDEO );
    try {
    p = Manager.createRealizedProcessor(
    new ProcessorModel( formats, outputType) );
    } catch( NoProcessorException e ) { System.out.println(e );
    } catch( CannotRealizeException e ) { System.out.println(e );
    } catch( IOException e ) { System.out.println (e );
    TrackControl track[] = p.getTrackControls();
    System.out.println("No. of tracks="+track.length);
    for (int i = 0; i < track.length; i++) {
    System.out.print("Track #"+i+": " +track[i].getFormat() + " \n" );
    } final DataSource source = p.getDataOutput();
    try {
    String filename = "movies.mpg"; // movie.avi
    String locator = "file://" + System.getProperty("user.dir") + System.getProperty("file.separator") + filename;
    MediaLocator dest = new MediaLocator(locator);
    try {
    fileWriter = Manager.createDataSink(source, dest);
    } catch (NoDataSinkException e) {
    System.out.println("The DataSink Exception tgv :" + e);
    } catch (SecurityException e) {
    System.out.println(e);
    fileWriter.addDataSinkListener(new DataSinkListener() {
    public void dataSinkUpdate(DataSinkEvent event) {
    if (event instanceof EndOfStreamEvent) {
    fileWriter.close();
    StreamWriterControl swc = ( StreamWriterControl)p.getControl(
    "javax.media.control.StreamWriterControl");
    if( swc != null) {
    swc.setStreamSizeLimit(1024 * 1024 );
    int delay = 2000; // delay for 2 sec.
    int period = 3000; // repeat every sec.
    Timer timer = new Timer();
    timer.scheduleAtFixedRate(new TimerTask() {
    public void run() {
    try {
    fileWriter.open();
    fileWriter.start();
    source.connect();
    source.start();
    p.start();
    } catch (IOException e) {
    System.out.println(e);
    System.out.println("File storage starts now \n ");
    try {
    Thread.sleep(3000);
    } catch (Exception e) {
    System.out.println("Error:" + e);
    System.out.println("File storage stops now \n ");
    p.stop();
    p.close();
    fileWriter.close();
    source.disconnect();
    source.stop();
    System.out.println("File is Sending now \n ");
    fis = new FileInputStream("C://movies.mpg");
    buffers = new byte[fis.available()];
    fis.read(buffers);
    oos.writeObject(buffers);
    oos.flush();
    fis.close();
    System.out.println("has been sent \n ");
    } catch (IOException ex) {
    Logger.getLogger(frm.class.getName()).log(Level.SEVERE, null, ex);
    }, delay, period);
    it works opens webcam start capture save into file ,sends over network then camera closes..
    my problem is camera should still opened.
    and as a lastformats[0] = new AudioFormat( AudioFormat.LINEAR);
    formats[1] = new VideoFormat(VideoFormat.RGB);
    FileTypeDescriptor outputType = new
    FileTypeDescriptor ( FileTypeDescriptor.MSVIDEO );
    try {
    p = Manager.createRealizedProcessor(
    new ProcessorModel( formats, outputType) );
    } catch( NoProcessorException e ) { System.out.println(e );
    } catch( CannotRealizeException e ) { System.out.println(e );
    } catch( IOException e ) { System.out.println (e );
    TrackControl track[] = p.getTrackControls();
    System.out.println("No. of tracks="+track.length);
    for (int i = 0; i < track.length; i++) {
    System.out.print("Track #"+i+": " +track[i].getFormat() + " \n" );
    } final DataSource source = p.getDataOutput();
    int delay = 2000; // delay for 2 sec.
    int period = 3000; // repeat every sec.
    Timer timer = new Timer();
    timer.scheduleAtFixedRate(new TimerTask() {
    public void run() {
    try {
    String filename = "movies.mpg"; // movie.avi
    String locator = "file://" + System.getProperty("user.dir") + System.getProperty("file.separator") + filename;
    MediaLocator dest = new MediaLocator(locator);
    try {
    fileWriter = Manager.createDataSink(source, dest);
    } catch (NoDataSinkException e) {
    System.out.println("The DataSink Exception tgv :" + e);
    } catch (SecurityException e) {
    System.out.println(e);
    fileWriter.addDataSinkListener(new DataSinkListener() {
    public void dataSinkUpdate(DataSinkEvent event) {
    if (event instanceof EndOfStreamEvent) {
    fileWriter.close();
    StreamWriterControl swc = ( StreamWriterControl)p.getControl(
    "javax.media.control.StreamWriterControl");
    if( swc != null) {
    swc.setStreamSizeLimit(1024 * 1024 );
    try {
    fileWriter.open();
    fileWriter.start();
    source.connect();
    source.start();
    p.start();
    } catch (IOException e) {
    System.out.println(e);
    System.out.println("File storage starts now \n ");
    try {
    Thread.sleep(3000);
    } catch (Exception e) {
    System.out.println("Error:" + e);
    System.out.println("File storage stops now \n ");
    p.stop();
    // p.close();
    fileWriter.close();
    //source.disconnect();
    source.stop();
    fis = new FileInputStream("C://movies.mpg");
    buffers = new byte[fis.available()];
    fis.read(buffers);
    oos.writeObject(buffers);
    oos.flush();
    fis.close();
    } catch (IOException ex) {
    Logger.getLogger(frm.class.getName()).log(Level.SEVERE, null, ex);
    }, delay, period);
    this code works open the webcam capture save and send over network contineusly with out giving any error
    It creates video in my local pc and send over network I  can see that video size is changing every seconds
    And fourtunately I am caming to my problem If I close processor "p.close()" program create video file but it can npt be rendered by any player
    it is some thing but I am sure that it is not a video
    If I close processor "p" camera still opened but video is not valid
    I know that I wrote lots of things but I could not figured out the problem and solution
    Thanks...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    You won't get any help because you've overloaded us with probably-irrelevant information and done nothing at all about trying to whittle the problem down to its roots. Plus, your subject line suggests that you're asking someone to write a fairly sizable bit of your app for you, and hence will get ignored by a lot of people
    Try and work out exactly what isn't working, and ask about it. As it is, you've written a load of code, it doesn't work, and you've just dumped it here expecting someone else to pick through it all and fix it - not going to happen
    And please, before you reply with some cutting comment about how unhelpful I am, consider that you'd been given no replies whatsoever so far

  • Problem with Sending files over Sockets

    Hi. I have a problem when I try to send files over sockets. When I send text files it works well but when I try to send .jpg or other kind of files it doesn't work well because some characters are wrong, I hope you can help me.
    Here is my code:
    //Sender code
    import java.io.*;
    import java.net.*;
    class Servidor{
         Servidor(){
              try{
                   String arch="art.jpg";
                   ServerSocket serv=new ServerSocket(125);
                   Socket socket=serv.accept();
                   System.out.println("Conectado");
                   int c;
                   BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
                   FileInputStream fis=new FileInputStream(arch);
                   File f=new File(arch);
                   bw.write(""+f.length());
                   bw.newLine();
                   bw.flush();
                   System.out.println("Escribiendo");
                   while((c=fis.read())!=-1){
                        bw.write(c);
                   bw.flush();
                   fis.close();
                   System.out.println("Terminado");
                   while(true){
              }catch(Exception e){
                   System.out.println(e);
         public static void main(String arg[]){
              new Servidor();
    //Client code
    import java.io.*;
    import java.net.*;
    class Cliente{
         Cliente(){
              try{
                   Socket socket=new Socket("localhost",125);
                   System.out.println("Conectado");
                   BufferedReader br=new BufferedReader(new InputStreamReader(socket.getInputStream()));
                   long tam=Long.parseLong(br.readLine());
                   long act=0;
                   FileOutputStream fos=new FileOutputStream("resp.jpg");
                   System.out.println("Recibiendo: "+tam);
                   while(act<tam){
                        fos.write(br.read());
                        act++;
                   System.out.println("Terminado: "+act+" / "+tam);
                   fos.close();
              }catch(Exception e){
                   System.out.println(e);
         public static void main(String arg[]){
              new Cliente();
    }

    I don't think you want BufferedReader and OutputStreamWriter, you want ByteArrayOutputStream and ByteArrayInputStream . The problem is that you are sending jpegs (binary data) as text.

  • Send many files through a socket without closing Buffered Streams?

    Hi,
    I have an application that sends/receives files through a socket. To do this, on the receiver side I have a BufferedInputStream from the socket, and a BufferedOutputStream to the file on disk.
    On the sender side I have the same thing in reverse.
    As you know I can't close any stream, ever.. because that closes the underlying socket (this seems stupid..?)
    therefore, how can I tell the receiver that it has reached the end of a file?
    Can you show me any examples that send/receive more than one file without closing any streams/sockets?

    Hi,
    As you know I can't close any stream, ever.. because that closes the underlying socket (this seems stupid..?)Its not if you want to continuosly listen to the particular port.. like those of server, you need to use ServerSocket.
    for sending multiple files the sender(Socket) can request the file to server (ServerSocket). read the contents(file name) and then return the file over same connection, then close the connection.
    For next file you need to request again, put it in loop that will be better.
    A quick Google gives me this.
    Regards,
    Santosh.

  • Send XML over Sockets

    I am beginning and I need to send XML formatted data from Swing Client to Server for parsing/processing/and response.
    There are no web server available to use. I think its best to use socket connection, but how do I send xml data over socket, and how do I receive it from server and parse it?
    I have read and cannot find a similar example.

    Xerces has DOMSerializer which can be used to serialize a Document object to a string. Once it's a string it's trivial to transmit over a socket connection. On the other side, to parse it, you'll have to create a StringReader for the received string and then an InputSource from the StringReader. You'll then be able to pass the InputSource to the DocumentBuilder.parse( ) method to generate a Document on the receiving side.
    Hope that helps,
    - Jesse

  • File sending failed repeats itself over and over (...

    I keep getting this error where "file sending failed" sound keeps playing at random intervals. Months ago there were some files that failed to send but it keeps notifying me of this over and over. This is definitely a defect of some kind. I hear the sound, I go to Skype, there are no new messages whatsoever. It then plays the sound 3-4 more times and goes quiet for a while. Truly a weird defect.
    Laptop is a Lenovo T420. I'm just trying to figure out if this affects other computers as well.
    Lenovo T420

    Using Windows Registry Editor (regedit) open this key:
    HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Skype\Phone
    What settings do you see set in the right hand panel?
    Can you see anything similar to this?
    http://community.skype.com/t5/Windows-archive/Windows-7-Skype-6-10-32-104-client-preferences-not-bei...

  • Can imessage send files size over 1gb to other mac?

    I am trying to send a file size about 1gb to another a friend who has macbook by using imessage.  I would see an exclamation mark next to the file i am trying to send. Is there a way to send large files through imessage?

    Hi,
    Messages can have the iMessages account and other non iMessage "Accounts" from AIM (Or valid with AIM) and Jabber IDs (which include Googlemail ones).
    These non iMessage Accounts are the ones that used to be used in iChat.
    Messages is effectively an iChat+ app
    File Transfers via the older "iChat Style" Buddy lists can be larger than email limits in some cases.
    There is an issue if the device you are sending a file to over iMessages is Off line.  The File Transfer will appear in the File Transfer window (See Window Menu) but not download/Sync when the device is back On line again.
    10:06 PM      Thursday; September 6, 2012
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
      iMac 2.5Ghz 5i 2011 (Lion 10.7.2)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • Filetransfer over sockets

    hi,
    im currently working on a filetransfer over sockets. this is what i do:
    i have a connection from the client to the server. on both sides i have a PrintStream for the output and a bufferedReader to read the responses. the client asks for a file and the server answers with the md5-hash size of the file, so that the client knows how many bytes it has to read. that works fine.
    now the filetransfer:
    the server writes the bytes of the file directly to the OutputStream (not the PrintStream). the client opens a BufferedInputStream on the mentioned socket and reads in as many bytes, as the server said before.
    now the problem:
    sometimes the filetransfer works fine, but sometimes some bytes are missing. i wonder where they are gone. it cant be a problem with the flush() method, because im using OutputStream to send the data. (i tested BufferedOutputStream with flush() with the same results).
    maybe it's not working because a attached a BufferedReader and a BufferedInputStream to the InputStream on the client-side...
    does anybody know, whats going wrong?
    let me know if you want to see some code.
    greetings,
    henrik

    i have solved this problem by using java.nio

  • XML parsing on messages over socket

    Hi,
    My java client gets the XML messages from server over a socket and I want to parse the message using the function parse(InputStream in) (for DOM parser) or parse(InputStream in, DefaultHandler h) (for SAX). But both these parsers are hanging and are waiting for end-of-file character which I guess is not possibl to send over a socket without closing the socket.
    Is there any way of making the parser not hang for input.
    Thanks
    Jeevan

    Have you tried to add the end of file character manually?
    // Some code left out here...
    char eof = (char)0x1A;
    // myXMLDocument is the document you want to send
    myXMLDocument += eof;
    //out is a PrintWriter object based on your OutputStream
    out.println(myXMLDocument);This worked for me!
    Regards,
    Erik.

  • FILE Adapter over HTTP

    Hi,
    Does anybody know if File Adapter woks with files over http?
    For example:
    I have a CSV file at http://xxx.com/file1.csv, I want to process this file and send to RFC Adapter.
    Can I put "http://xxx.com/" in "Source Directory" of file sender communication channel?
    Any sugestions? (FTP is not a choice)
    regards,
    Luiz Alberto

    Hi Luiz,
       I don't think this will work with File Adapter.
    Thanks and Regardds,
    Chandu.

  • File sender adapter (FTP) - processing mode "Archive"

    Hello all
    We're polling files from an external FTP server. For this I created a scenario on XI according to this thread:
    When setting processing mode to "Archive" in the file sender adapter (ftp) it polls the file, stores it to the archive directory I specified and then tries to delete the file on the FTP server side. This returns me an error because we're not allowed to delete the retrieved files on the FTP server!
    Because of this error the file adapter stops further processing and does not poll all the other files.
    How can I disable this deletion mechanism while keeping processing mode to "Archive"?!?!?
    We do not want to use processing mode "Delete" or "Test" and we don't see other options to influence this behaviour.
    Thanks for any guideance on this one in advance!
    Kind regards,
    Renaud

    Hi Bhavesh
    Sorry for the late answer. Unfortunately I can't ask the application system to provide file names containing a timestamp within. The files are provided by an external partner and are retrieved by several others as well.
    In the meantime I managed to achieve this:
    In repository I created dummy data types, message types and message interfaces. No mapping programs and interface mappings!
    In configuration I created the necessary communication channels (1 ftp sender, 1 file receiver) and the required receiver and interface determinations as well as the sender and receiver agreements.
    The result of this is:
    I'm able to poll some specific files via ftp from remote host. The file names are file1.arj, file2.arj, file3.arj and file4.arj. All 4 files have the same SourceFileTimestamp (e.g. "20060727T053900Z").
    I'm able to store those 4 files 1:1 in a target directory with the same file names. Until here I did NOT need to follow this blog: <a href="/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14: The same filename from a sender to a receiver file adapter - SP14</a>.
    As of this blog it is possible to access adapter specific attributes and make them available in message mapping using user defined functions. This way I'm able to get the SourceFileTimestamp from the polled files and use it in a message mapping. This way I'm also able to use it in variable substitution on file receiver adapter (syntax = "payload:root,1,fileTS,1") in order to dynamically create a directory with this syntax: YYYYMMDD.
    So far so good... but the only remaining BIG problem now is, that as soon as the mapping is activated and assigned in the interface determination, the created files contain the XML payload instead of the original binary content. Where has it gone? How should the target message type look like so that it can carry over the original binary file content?
    BTW: isn't it possible to post screenshots? Would be much more easier to explain things... so sorry to anyone if I wasn't clear enough!
    TIA and best regards,
    Renaud

  • File sender adapter is not working

    Hello All,
    We are facing a problems with file sender adapter. Communication channel is not picking the files from the directory, but the status in RWB for that channel is 'Functioning'. We are not sure whether the channel is locked or any other problewm with adapter. (In Alternate option, we have created copy of that channel and when it is activated, it picked the file )
    Can anyone help us how to identify whether channel is locked and any other solutions in this case.
    Regards,
    Sreenvias.

    Hi Srinivas,
    The file adapter ( The respective channel) is definitely locked in PI . Ideally for each polling interval a lock is being created and once the processing is over , the lock should be released/deleted automatically to allow further polling interval. If the lock is not released by the system automatically,further polling will not happen as expected. ( This may affect all sender file adapters as well. I would recommend to do a check in al sender file communication channels)
    You can see/delete the locks in Visual admin.
    Go to Server>Services->Locking adapter  and click refresh
    The entries for file adapter ( with name $XIAFFileAdapter) should be deleted by selecting those particilar entries and click delete selected locks.
    If you have more than one node, then same should be done in all server nodes.
      The temprory solution would be creating/copy the existing channel in ID with same properties and assign it into particular sender agreement.
    But, the lock may be created again which potentailly stops all your file based interfaces. Hence i would suggest to use Timeout parameter avialable in file sender adapter which termiates FTP session as you defined, This should solve your issue permanently.
    The FTP server do have thier own time out settings but if you don't defne any particulat time out in PI, the FTP server forcefully disconnects the FTP sessions which created locks in PI.
    Hope this solves your issue.
    PS: The same bahaviour would expected for all sender JDBC adapter as well

Maybe you are looking for

  • Windows doesn't recognize my ipod

    I have the 30gb video ipod and when i was playing a game it froze. So I connected it to my computer and itunes loaded up and it said my ipod was currupt and i should reinstall the software. So I did and it started to when my computer froze (which has

  • Give a checkbox a variable name.

    I am using a Flash form to add/edit records in an MS Access Database via ASP. It's working great for all of the text fields, because I just refer to the variable names in my ASP script and it updates the corresponding field in the Access database. Ho

  • Can't get tab leaders to work

    CS4 I'm trying to set a right tab leader with an underscore. I can't get it show (or any other). Is this a program glitch or something? I checked the forums and saw no previous relevant posts. Thanks

  • Screenpainter

    how to create the background in screenpainter?

  • Unicode type X issue

    Hi, I have code " X1 type X value '13'                       X2 type X value '10' " Can anyone tell me how to replace this code ; like for X1 type X value '09' can be replaced with CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB  class. Thanks in advance! Reg