Transfer a file thought a socket

Hi, i am trying to transfer via web a file from the server to my PC, when i do a txt file transfer all goes allright, but when i try to transfer an other kind of file as a dll the files are diferent, i don't know why it happens this. How could i do this?.

Rather wide field for errors. How about some code? My first question would be: Are you by any chance using Readers or Writers on the Streams on either end? They apply an extra character encoding to the data transferred.

Similar Messages

  • How to transfer a binary file through the socket?

    hi,
    i have a problem when I want to transfer a binary file through the socket. On the server side we write a program with C. On the client side with use java. The socket worked fine when we transfer some asci files. But failed when transfer the binary file. How to solve the problem? Can someone give me some advice? Thanks a lot.
    sincerely,
    zheng chuanbo

    i use streams to read the binary file. The problem is I don't know when the transfered stream finished. With text file I can recognize the end of the transfer by a special string, but how to deal with the end of a stream? should the server send an "EOF" or something else to the client to notify the end?

  • How do I transfer PDF files from PC to IPAD using Itunes 12.1.2.  Previous versions let me drag file in Itunes to Ipad and files appeared under Ibook but can't get it to work in latest 12.1.2 version.

    How do I transfer PDF files from PC (Windows 7) to IPAD using Itunes 12.1.2.  I would like to do files manually rather then auto synch.  Previous versions let me drag file in Itunes to Ipad and files appeared under Ibook and then I could move them to an appropriate collection title.  The interface appears to have changed in the latest ITunes version and I am not sure what the proper procedure is.

    King_Penguin - Thanks it worked perfectly.  I had my pdf files copied into ITunes on my PC but when I clicked on a pdf file to copy it I thought the sidebar would appear with my IPAD name and then I would drag it over.  I didn't realize that I needed to click-and start dragging it towards the left-hand side for the sidebar to appear.  It worked like a charm - THANKYOU!!!

  • Sending a File Using DataGram Sockets

    I writting one java program that can be used to transfer a file from one computer to another computer.
    I wrote using Sockets.
    But i want to do that using DatagramSockets. Can we send a file using DataGramSockets?
    Please reply soon.

    You can use DataGram but it is harder.
    One issue is you need to retransmit missing packets. This means you need to keep track of which packets have been sent and be able to send missing ones again.
    If Socket work for you why do you want to use DataGrams

  • Problems sending files throught TCP sockets

    I would like to transfer a file throught a tcp socket, here there is what the sender program does :
    try{
         File localFile = new File("shared/"+fileName);
         DataOutputStream oos = new DataOutputStream(socket.getOutputStream());     
         DataInputStream fis = new DataInputStream(new FileInputStream(localFile));
         while(fis.available() > 0){
              oos.writeByte(fis.readByte());
         catch(Exception e){}here what the receiver program does:
         try{
         File downloadFile = new File("incoming/"+fileName);
         downloadFile.createNewFile();
         ois = new DataInputStream(connectionSocket.getInputStream());
         fos = new DataOutputStream(new FileOutputStream(downloadFile));
         while(ois.available() > 0){
              fos.writeByte(ois.readByte());
         catch(Exception e){}
    }Where i m wrong? it doesnt work :( , it just create the new file in the incoming folder, but its size remains 0 byte :(
    help a newbye please :D

    Your problem is probably related to the use of available. This is the amount that is currently in the buffer that you can read without blocking. For network programming you should expect to have to wait for data. Second, you are copying the data one byte at a time which is not very efficient. Try something like:
    // Sender
    try {
        File localFile = new File("shared/"+fileName);
        OutputStream out = socket.getOutputStream();     
        InputStream fis = new FileInputStream(localFile);
        int length;
        byte[] buffer = new byte[4096];
        while((length = fis.read(buffer)) != -1)
         out.write(buffer, 0, length);
        fis.close();
        out.close();
    catch(Exception e){}
    // Receiver
    try {
        File downloadFile = new File("incoming/"+fileName);
        IntputStream ois = connectedSocket.getIntputStream();     
        OutputStream fos = new FileOutputStream(downloadFile);
        int length;
        byte[] buffer = new byte[4096];
        while((length = ois.read(buffer)) != -1)
         fos.write(buffer, 0, length);
        fos.close();
        ois.close();
    catch(Exception e){}

  • Problem trying to transfer multiple file over a network or the internet

    Hello I'm trying to make a file transfer program to transfer file over the internet or a network. I've been able to successfully transfer one file but when I try to send multiple files I keep getting a EOFException after the client trys to send the files. The client says it sent both files and the connection was closed but the server said that it only received one file and throws a EOFException. I've included the code from the client and the server. Any help is much appreciated.
    The Client
    private class createSocket implements Runnable {
              String address;
              int port;
              public createSocket ( String address, int port ) {
                   this.address = address;
                   this.port = port;
              public void run() {
                   try {
                   postStatusMsg( "Opening Connection at " + address + ":" + port );
                   Socket socket = new Socket( address, port );
                   postStatusMsg( "Connected to " + address + ":" + port );
                   DataOutputStream dos = new DataOutputStream( socket.getOutputStream() );
                   DataInputStream dis = new DataInputStream( socket.getInputStream() );
                   dos.writeInt( files.length );
                   for ( File f : files ) {
                        BufferedOutputStream out = new BufferedOutputStream( dos );
                        BufferedInputStream in = new BufferedInputStream( new FileInputStream(f) );
                        postStatusMsg( "Sending: " + f.getName() );
                        byte[] b = new byte[8192];
                        int read = -1;
                        dos.writeUTF( f.getName() );
                        while ( ( read = in.read( b ) ) >= 0 ) {
                             out.write( b, 0, read );
                        postStatusMsg( "File Sent" );
                        in.close();
                   dos.close();
                   postStatusMsg( "Closing Connection" );
                   socket.close();
                   postStatusMsg( "Connection Closed" );
              catch( IOException e ) {
                   Main.ShowMsgBox( statusTA, "Error", e.getMessage(), JOptionPane.ERROR_MESSAGE );
                   try {
                        e.printStackTrace( new PrintStream( "./log.txt" ) );
                   catch ( FileNotFoundException ee ) {
                        ee.printStackTrace();
         }The Server
    public class ServerHandler implements Runnable {
              private Socket s = null;
              public ServerHandler( Socket s ) {
                   this.s = s;
              public void run() {
                   try {
                        handlers.add( this );
                        DataInputStream dis = new DataInputStream( s.getInputStream() );
                        DataOutputStream dos = new DataOutputStream( s.getOutputStream() );
                        BufferedInputStream in = new BufferedInputStream( dis );
                        BufferedOutputStream out = null;
                        int count = dis.readInt();
                        for ( int i = 0; i < count; i++ ) {
                             File f = new File( Main.settings.SAVE_DIR );
                             if ( !f.isDirectory() )
                                  f.mkdir();
                             f = new File( Main.settings.SAVE_DIR + "\\" + dis.readUTF() );
                             out = new BufferedOutputStream( new FileOutputStream( f ) );
                             postStatusMsg( "Receving: " + f.getName() );
                             byte[] b = new byte[8192];
                             int read = -1;
                             while ( ( read = in.read( b ) ) >= 0 ) {
                                  out.write( b, 0, read );
                             postStatusMsg( "File Received" );
                             out.close();
                        in.close();
                        postStatusMsg( "Closing Connection" );
                        s.close();
                        postStatusMsg( "Connection Closed" );
                        handlers.remove( this );
                   catch ( IOException e ) {
                        Main.ShowMsgBox( statusTA, "Error", e.getMessage(), JOptionPane.ERROR_MESSAGE );
                        try {
                             e.printStackTrace( new PrintStream( "./log.txt" ) );
                        catch ( FileNotFoundException ee ) {
                             ee.printStackTrace();
         }

    Something like this, modulo bugs:
    // sender
    dos.writeLong(file.length());
    // send the file
    // receiver
    long length = dos.readLong();
    long current = 0;
    int count;
    while (current < length && (count = in.read(buffer, 0, (int)Math.min(buffer.length, length-current))) > 0)
      out.write(buffer, 0, count);
      current += count;
    }

  • Can't transfer large files with remote connection

    Hi all,
    I'm trying to figure out why we can't transfer large files (< 20MB) over a remote connection.
    The remote machine is a G5 running 10.4.11, the files reside on a Mac OS X SATA RAID. We are logged into the remote machine via afp with an administrator's account.
    We can transfer files smaller than 20 MB with no problem. When we attempt to transfer files larger than 20 MB, we get the "The operation can't be completed because you don't have sufficient permissions for some of the items."
    We can transfer large files from the remote machine to this one (a Mac Pro running 10.4.11) no problem.
    The console log reports the following error:
    NAT Port Mapping (LLQ event port.): timeout
    I'm over my head on this one - does anyone have any ideas?
    Thanks,
    David

    I tried both these things with no luck.
    The mDNSResponder starts up right after the force quit - is this right?
    The following is the console log, which differs from the previous logs where we had the same problem:
    DNSServiceProcessResult() returned an error! -65537 - Killing service ref 0x14cb4f70 and its source is FOUND
    DNSServiceProcessResult() returned an error! -65537 - Killing service ref 0x14cb3990 and its source is FOUND
    DNSServiceProcessResult() returned an error! -65537 - Killing service ref 0x14cb2b80 and its source is FOUND
    DNSServiceProcessResult() returned an error! -65537 - Killing service ref 0x14cb1270 and its source is FOUND
    Feb 4 06:13:57 Russia mDNSResponder-108.6 (Jul 19 2007 11: 41:28)[951]: starting
    Feb 4 06:13:58 Russia mDNSResponder: Adding browse domain local.
    In HrOamApplicationGetCommandBars
    In HrOamApplicationGetCommandBars
    In HrOamApplicationGetCommandBars
    Feb 4 06:23:12 Russia mDNSResponder-108.6 (Jul 19 2007 11: 41:28)[970]: starting
    Feb 4 06:23:13 Russia mDNSResponder: Adding browse domain local.
    Feb 4 06:26:00 Russia configd[35]: rtmsg: error writing to routing socket
    Feb 4 06:26:00 Russia configd[35]: rtmsg: error writing to routing socket
    Feb 4 06:26:00 Russia configd[35]: rtmsg: error writing to routing socket
    Feb 4 06:26:00 Russia configd[35]: rtmsg: error writing to routing socket
    Feb 4 06:26:00 Russia configd[35]: rtmsg: error writing to routing socket
    Feb 4 06:26:00 Russia configd[35]: rtmsg: error writing to routing socket
    Feb 4 06:26:00 Russia configd[35]: rtmsg: error writing to routing socket
    Feb 4 06:26:00 Russia configd[35]: rtmsg: error writing to routing socket
    [442] http://discussions.apple.com/resources/merge line 4046: ReferenceError: Can't find variable: tinyMCE
    Thanks,
    David

  • Can't transfer shared files

    I have an Ethernet network that I have used for many years with 2 Macs - the latest being two iMacs (1 x Intel running Snow Leopard (10.6.8) and 1 x PPC running Tiger (10.4.11).  I have never had any (unsolvable) problems transferring  files over the net, either way, between the 2 iMacs. 
    Last month, I bought a new iMac running Lion (10.7.3) and connected it to my network (via my Ethernet/Internet router).  All seems OK, in that I can access any of my iMacs.
    However, I can only transfer files between the Lion Mac and the Tiger Mac (both ways), or between the Snow Leopard Mac and the Tiger Mac (both ways).  I cannot transfer files between the Lion Mac and the Snow Leopard Mac in either direction.
    With the Lion/Snow Leopard attempted transfer, I am asked for my password to transfer a file (either way), I enter my password and either Mac then goes off into a never-ending transfer, which I am unable to stop.  As an example, I tried to transfer an Excel Workbook (something I've done for years with the two older Macs).  The transfer consisted of 5,830 files each containing no data !!  I only managed to stop the transfer by (literally) pulling the plug out of the electricity socket on the Lion iMac.  It then took a huge amount of time to trash these 5,830 files.
    I have checked and rechecked Sharing etc. but can find nothing incorrect.  Given that I can transfer between Lion & Tiger or between Snow Leopard & Tiger, I cannot see how I have set up sharing incorrectly.
    Any ideas would be most welcome as it is all rather tedious to transfer via my Tiger iMac every time!
    Thanks
    Patricia

    hi Colin!
    Just giving a heads up - It's appeared in the iTunes for Mac now but it is marked as solved.
    i got the email notification for your post, came here, looked up at the top of the Window, and saw where i had been transported ... ahhhh! the light! it burns!
    That can only be changed by the OP, not the act of moving it across?
    yeah, this one was already marked as answered when i hooked into again over at the dark side prior to making my previous post. so the answered status isn't an artifact of the movement to the new forum.
    (actually, Hosts can also change the status of a thread to answered. that can be useful when cleaning up duplicate "question" posts ... if the "deleted" duplicate isn't marked as answered, i believe the OP could get an unresolved question stuck in their "My Questions". i don't know if that's currently still an issue, though.)
    jegslim: it would be worth marking this thread as unanswered again. that might increase the chances of it being read (at least a little bit).
    love, b

  • Can't transfer photo files from old iBook to Mac Pro

    When I travel, I upload my photos using a card reader onto my iBook (1.2Hz, 762 RAM). At home, when I try to transfer them to my Mac Pro Quad (2.66Hz, 3Gb RAM) the transfer always starts OK (a number of files transfer) but then stalls out on a particular file. If I go back to my iBook and remove the "stalled" file, then try the transfer, it starts OK and then stalls on a new file, further "down the list".
    So I basically can't transfer the files. Curiously, I have tried transfering the files from my iBook to a CF card and the same thing happens, so it seems the issue is with the iBook. Why would it be an issue only in one direction, ie, no problem uploading the files onto the iBook from my CF card reader? Could this be a memory issue? Any thoughts or suggestions?? Thanks.

    I suspect a bad HD in your iBook. Pretty much anything that involved stalling and HDs means that.

  • File reading through Sockets???

    Hello,
    My application has a server and it has to read a file that is sent by the client.. how can the server read a file sent by the client through sockets?????
    Edited by: s_coder on Feb 19, 2009 11:20 PM

    s_coder wrote:
    Yes i read it but there input is given from the client to the server through the standard input stream.... how can i transfer a file thru the standard input stream? and the accept it at the server side???Come on mate. You need to be able to add two and two on your own.
    WTF is a "standard input stream"? And why if you followed the tutorial can you not figure out how to send the data of a file through a socket?
    Either you didn't really read the tutorial or you're pretty darn hopeless. Why don't you try and really follow the tutorial, not just glance at each page but understand what it is saying. Then make an attempt to write your program and if you get stuck come back with your code. Be sure to use the code formatting tags when you show us your code.

  • How to transfer playlist files to USB disk

    Okay, so I have a nice playlist full of 8 GB of music, now I want to transfer those files (in no particular order) onto my mini USB thumb drive to use in my car. What is the best way to do this in an organized way? I was thinking of right clicking on every album and "reveal in finder", then manually transfer that album's folder to keep it all organized in the USB drive. I'm trying to setup a few USB drives to function like an old multi-CD changer would. Any better ways before I waste some time?
    Thanks!

    Thanks for the response Limmos. I tried this, but unfortunately all the files go into a single directory, so there is no folder organization anymore, so I loose all my album searching options in the car (requires folders).
    I thought about this last night and I had an idea. I'm thinking of copying all the files to the drive as you described above, then restarting itunes with the option key held down, forcing it to create a new library, adding all the files with are now on the drive to the new blank library, and then run the Library> organize library. Would that work?

  • Transfer a file in Java

    Hi
    My requirement is to write a code where I can transfer a file from client machine (when he selects browse button and ok) to server (where application is hosted).
    In other words, I have to get a file from client.
    Now, I dont' have to first read contents of file in java and then create a new file in server, and paste these contents in that file.
    Is there any way by which I can just transfer this file from client machine to server.
    i understand there is a method called "Socket" programming.
    But is this the only way.
    Because as I have understood, in socket programming, a code module has to be running on client machine as well !
    Am I right
    Is there not another way to do this ?
    Thanks in advance
    Edited by: money321 on Apr 6, 2010 2:58 PM

    You could have a servlet where your doGet or doPost method does something like this:
            File serverFilePath = new File(getServletContext().getRealPath("/"));
            serverFilePath = new File(serverFilePath, "uploads");
            serverFilePath.mkdir();
            DiskFileItemFactory factory = new DiskFileItemFactory();
            ServletFileUpload upload = new ServletFileUpload(factory);
            if (ServletFileUpload.isMultipartContent(req)) {
                try {
                    List<FileItem> fileItems = upload.parseRequest(req);
                    for (FileItem each : fileItems) {
                        //iterate through fields that are not standard form fields
                        if (!each.isFormField()) {
                            if (each.getName() == null || each.getName().length() == 0) {
                                continue;
                            File currFile = new File(each.getName());
                            currFile = new File(serverFilePath, currFile.getName());
                            each.write(currFile);
                catch (Exception e) {
                    throw new RuntimeException(e);
            }The DiskFileItemFactory and ServletFileUpload are from the apache commons fileupload library. In your html form, make sure you set the enctype to be multipart/form-data. Then just have input fields for each file the user wants to upload, setting the type to be file.

  • Unable to transfer large files from MB to External HDs

    Hi,
    This may be an unusual one. My 1st edition Macbook won't let me transfer large files to my external hard-drives, either by USB, Ethernet or wirelessly through my home wi-fi network.
    I've started video editing so I'm importing DVcam tapes through firewire from the camera. A full DV tape translates to about 8-12gb I think.
    Using iMovie and saving the import to my Freecom 3.5inch network harddrive vis USB or ethernet, it fails saying 'Unexpected error, error code 1309'.
    When I try quicktime pro instead to import the tape to the external HD, I get 'Operation could not be completed, An attempt to add a resource to the file failed'. This happens too with my WD 2.5inch external drive.
    However, there is no such problem when I import to the MB's internal harddrive. When I then try and shift the large file off the laptop to an external drive, via USB, ethernet of wirelessly, for editing and save keeping, it fails half way through.
    I have the same problem when I try back-up my 17gb virtual windows machine I use with VMware fusion off the laptop to an external drive.
    I am currently burning an 18gb iMovie project from the MB's internal HD, over 5 DVDs using Toast's disc-spanning and will reimport them to the external, which is really time consuming.
    Also to note, Final Cut Express doesn't have these problems as it seems to break up what would be an 18gb movie file into several smaller files, which my MB is quiet happy to let go onto an external drive. However, the problem re-emerges on Final Cut Ex when I try and import a HDV tape. Possibly FCE isn't breaking them up into small enough pieces for my MB to handle?
    Any ideas why this is happening and what I can do to fix it? Or does this mean a new laptop?

    Irish Apple Fan wrote:
    Hi,
    This may be an unusual one. My 1st edition Macbook won't let me transfer large files to my external hard-drives, either by USB, Ethernet or wirelessly through my home wi-fi network.
    I've started video editing so I'm importing DVcam tapes through firewire from the camera. A full DV tape translates to about 8-12gb I think.
    Using iMovie and saving the import to my Freecom 3.5inch network harddrive vis USB or ethernet, it fails saying 'Unexpected error, error code 1309'.
    When I try quicktime pro instead to import the tape to the external HD, I get 'Operation could not be completed, An attempt to add a resource to the file failed'. This happens too with my WD 2.5inch external drive.
    I'm a bit late to the party, but specifically there's a 4GB file size limit in the FAT32 format that is standard on many external hard drives. I've run across this problem before, and usually it copies over most of the file and then quits when it reaches the limit.

  • How do I make space on my MBP and transfer old files to External Hard Drive?

    I recently ran out of the 250 GB space on my 2010 Macbook Pro, so I bought a non-apple external hard drive. I plugged it in and Time Machine automatically popped up.
    I just wanted to know what the correct way to transfer all my old files that I'm not using any more and still want to keep to the external hard drive and not use the external hard drive as a "backup" for my laptop but rather as just a place to keep all the files I'm not currently using. Do I just use Time Machine and turn off the automatic back ups? Is there a certain way to transfer individual files to the EHD later (does this happen through Time Machine or just dragging them in through Finder?)?
    I've never used an EHD so I'm really unsure on how all this works on a Mac since the instruction manual only gave instructions for PC's even though it is Mac compatible.
    Thanks in advance!

    Apple doesnt make hard drives, they use Toshiba/Hitachi inside current macbook pro non-retina.
    You should always have a backup regardless, and 2 at that. One backup, and one archive, unless losing valuable data is no consideration to you.
    use time machine as a backup for restoration /emergency backup and use a separate HD for archiving valuable data.
    Using an external HD is as easy and falling down. Buy a nice Hitachi/Toshiba or Seagate external HD, format it in disk utility for MAC OSX extended journaled and drag and drop ALL your valuable data to same and updata as needed.
    a nice 1TB external HD is currently running $65
    backup with time machine,
    ARCHIVE all valuable data, ,music, pics, files, videos etc etc onto ANOTHER hard drive.
    2 backups is 1, and 1 is none. 
      If you always follow that rule that should be written in stone, you'll never be sorry.... (and I know countless 1000s that have been)

  • How to transfer file from ipod touch to i tunes. i have files in my ipod , ut itunes is  new so its telling if u sync the ipod all the files will be replaced but no files in the itunes.. so kindly help me how to transfer the files  from i pod to itunesb

    how to transfer file from ipod touch to i tunes. i have files in my ipod , ut itunes is  new so its telling if u sync the ipod all the files will be replaced but no files in the itunes.. so kindly help me how to transfer the files  from i pod to itunes......

    Some of the information below has subsequently appeared in a document by turingtest2: Recovering your iTunes library from your iPod or iOS device - https://discussions.apple.com/docs/DOC-3991
    Your i-device was not designed for unique storage of your media. It is not a backup device and media transfer was designed for you maintaining a master copy of your media on a computer which is itself properly backed up against loss. Syncing is one way, computer to device, updating the device content to the content on the computer, not updating or restoring content on a computer. The exception is iTunes Store purchased content.
    iTunes Store: Transferring purchases from your iOS device or iPod to a computer - http://support.apple.com/kb/HT1848 - only media purchased from iTunes Store
    For transferring other items from an i-device to a computer you will have to use third party commercial software. Examples (check the web for others; this is not an exhaustive listing, nor do I have any idea if they are any good):
    - Senuti - http://www.fadingred.com/senuti/
    - Phoneview - http://www.ecamm.com/mac/phoneview/
    - MusicRescue - http://www.kennettnet.co.uk/products/musicrescue/
    - Sharepod (free) - http://download.cnet.com/SharePod/3000-2141_4-10794489.html?tag=mncol;2 - Windows
    - Snowfox/iMedia - http://www.mac-videoconverter.com/imedia-transfer-mac.html - Mac & PC
    - iexplorer (free) - http://www.macroplant.com/iexplorer/ - Mac&PC
    - Yamipod (free) - http://www.yamipod.com/main/modules/downloads/ - PC, Linux, Mac [Still updated for use on newer devices? No edits to site since 2010.]
    - 2010 Post by Zevoneer: iPod media recovery options - https://discussions.apple.com/message/11624224 - this is an older post and many of the links are also for old posts, so bear this in mind when reading them.
    Syncing to a "New" Computer or replacing a "crashed" Hard Drive - https://discussions.apple.com/docs/DOC-3141 - dates from 2008 and some outdated information now.
    Copying Content from your iPod to your Computer - The Definitive Guide - http://www.ilounge.com/index.php/articles/comments/copying-music-from-ipod-to-co mputer/ - Information about use in disk mode pertains only to older model iPods.
    Get Your Music Off of Your iPod - http://howto.wired.com/wiki/Get_Your_Music_Off_of_Your_iPod - I am not sure but this may only work with some models and not newer Touch, iPhone, or iPad.
    Additional information here https://discussions.apple.com/message/18324797

Maybe you are looking for