Streaming Files over networks

Hi,
I am new to java. Have been trying to work on a system that transfers files from one machine to another (remote) machine.
I am basically using a FileInputStream combined with BufferedOutputStream in my server, where I am (right now) transferring byte after byte to the BOF and then flush it to the network.
On the other end I am using a FileOutputStream with BufferedInputStream. Am using a BufferedOutputStream to wrap the FileOutputStream. I read the BIS byte by byte and transfer it to the BOS. When I flush it, it is supposed to write to the File via the FOS.
I have tried various combinations and possibilities, like .. different read write methods ... and readers and writers.
PROBLEM
The basic problem is that when my client reaches the end of the file it is supposedly reading (from the network), it halts. It stops ... doesnt go anywhere. The snippet is as follows .. the while check gets stuck when it is supposed to get out.
while((ch=fileStream.read()) > -1)
bos.write(ch);
System.out.println("File Recieved, Enter new command");
bos.flush();
I would be really grateful if someone gives me a pointer.
[this particular problem, amongst others, is consistent for all combos I have tried]

When the file is done on the server side (writer), does it close the connection? If not, it's never going to get the -1 on the client side (reader) to break the loop.
If you can't close the connection, then you have to come up with some sort of protocol to allow your endpoints to talk in a more meaningful way. At the very least, start the transfer with the file size and only read that much on the client. Or some other start/end of stream markers that the client side can look for. Or just get an FTP server/client code (maybe TFTP) for Java and use that.

Similar Messages

  • Transferring file over network? what can I use besides ssh?

    What can I use to transfer file over network besides using ssh?
    This is only for experimental purposes. I have used ssh before, by using command like this:
    (time cat /run/shm/test/input/totalInput.tar | ssh username@ip-server "cat > /dev/null") 2>>/run/shm/test/p3_UC_ctime_tar.txt
    or this, if I tried to compress a file and then transfer:
    (time bzip2 -kfc1 /run/shm/test/input/totalInput.tar | ssh username@ip-server "cat > /dev/null") 2>>/run/shm/test/p3_ctime_tar.txt
    However, I think ssh is killing my transfer speed. I am getting only 10-20Mbps.. Router should support over 200-300Mbps.
    What can I use besides ssh? I was thinking about netcat, but what I don't like is that I have to open port on the other side for each new file transfer.

    Well, what I am conserned with things like scp and ssh (I tried scp too) is encryption.
    I just moved one file over to a server with scp, and I got about 2.1MB/s... which is about 16.8 Mbps..
    I am using Linksys E900, which is wireless-N router. Connection exist between two computers only, nothing else is using that router. However, there is another wireless point outside of our room, which is used for public University network. I don't know how much of effect it would have on our set up.
    Both computers have plenty of disk space. One computer (actually development board) uses sd-card for its OS and other disk space.
    About 200-300Mbps.. is just something I saw on router's specs.
    Last edited by kdar (2012-08-19 03:22:28)

  • Streaming .wav file over network

    Hi ,
    I am trying to stream a .wav file over the network using datagram sockets and packets. When it gets to the other end it is just noise but you cannot make out what the music is.
    Any ideas would be most appreciated!
    code below
    byte[] data;
    int bytesAvailable;
              String     strFilename = "test.wav";
              File     soundFile = new File(strFilename);
              AudioInputStream     audioInputStream = null;
              try
                   audioInputStream = AudioSystem.getAudioInputStream(soundFile);
              catch (Exception e)
                   e.printStackTrace();
                   System.exit(1);
    while (thread != null) {
              int     nBytesRead = 0;
              byte[]     abData = new byte[EXTERNAL_BUFFER_SIZE];
              while (nBytesRead != -1)
                   try
                        nBytesRead = audioInputStream.read(abData, 0, abData.length);
                   catch (IOException e)
                        e.printStackTrace();
                   if (nBytesRead >= 0)
    try {
    connection.send(new DatagramPacket(abData,1000));
    }catch(Exception exec) {
    System.out.println("Record: Exception sending packet:\n"+exec.getMessage());
    try {
    thread.sleep(50);
    }catch(InterruptedException exec) {}
    }

    Streaming? looks like your dumping the whole file into a datagram packet. How are you receiving it on the other end?

  • Copy files over Network - sometimes message "insufficent access priv"

    Hi have a MacBook Pro & a MacPro.
    I copied big files wirelessly all the time.
    I software updated to QuickTime 7.1.6 and now I have two issues.
    1) When I try to pull files over the network, I often get the message "insufficent priveleges". The file is in the middle of copying, so it starts the process just fine. I am logged in as a registered user. I can copy the files from the Mac Pro to the laptop.
    2) I used to be able to stream video over my wireless without a hitch (even on my old Powerbook g4). Now streaming video plays for a few a few minutes and locks up.
    It seems the update did something bad. However QT video plays fine locally from my laptop harddrive.
    Anybody with similar problems or know any solutions?

    Thanks for the tip. I tried repairing permissions and lots of things were fixed on the laptop but the problems remain.

  • Accessing shared files over network

    I am having some problems with a couple of database files that I access with a Java program over network. Different computers running this program all need access to these files, and my question is if anyone know of a good way to make sure that only one user have access to these files at the time. There is no server software running were the files are stored, they are simply reached through file sharing. Currently I am creating a lock file indicating that someone is editing the files, however if I am unlucky 2 users create that lockfile at the same time and then both get access to the file corrupting it. Anyone experienced this and know of a nice solution to avoid it?

    I am having some problems with a couple of database
    files that I access with a Java program over network.
    Different computers running this program all need
    access to these files, and my question is if anyone
    know of a good way to make sure that only one user
    have access to these files at the time.Use a database server instead.

  • Crashing in PS CS and Quark when opening files over network

    Mac Pro and MacBook Pro 10.4.8 using Adobe Photoshop CS2 and Quark 6.52 will crash or become VERY unstable when opening files from server or remote machine. Server is 10.3.9 or remote Mac running 10.4.7, all works fine IF file are copied to client machine, but cannot use -File/Open dialog. This is a network isue in relation to Intel translation, is there a fix (Rosetta?)

    Try looking for some "special" characters in file or folder names ( e.g. / or ?).
    I had similar problems with PPC-Apps (InDesign CS2 and 4D Client 2003) since 10.4.7 and 10.4.8. App crashes or shows strange grey boxes on the screen when I tried to open files over the network, no probs with same files locally.
    MacBook Pro   Mac OS X (10.4.8)  

  • Sharing Files Over Network and computers not showing up in sidebar

    I am trying to figure out how to share files over the network. Now when I click onto the computer in my shared items, I do not get access to the home folder that I used to see. Instead, I am getting a folder image with the user name below it, but it says Sharepoint. However, when I click on the folder I get another folder that says dropbox with a down arrow. However, when I click on that it says it cannot be opened because I do not have privileges.
    What happened to being able to being able to get access to the home folder from the users on the computer that you are trying to retrieve files from.
    Are there settings I need to adjust to allow me to get access to the files on the other computer.
    The other computer is an iMac G5.
    My next issue is that my wife's iBook G4 doesn't even show up in the shared items in the sidebar.
    Again, are there settings on this computer that have to be adjusted.
    Thanks in advance.
    Russell
    Message was edited by: Russell Massey

    Hi Henry, and a warm welcome to the forums!
    While you may get help or a solution here, It's quite acceptable to start a new topic of your own, certainly feel free to start a new topic to attract more helpers to your particular situation, here's a link if as is often the case, it's hard to find out where to do it...
    http://discussions.apple.com/post!default.jspa?forumID=752
    It asks me to loggin I dont remember ever setting a login and password for it.
    You need to add a User to the PC, or try with the PC's username & PC's Password.
    My Main Problem is that my PC can see my Macbook...
    On the Mac, did you enable Windows Sharing in System Preferences>Sharing>Services ?
    I want to be able to use my printer that is hooked up to my Windows 7 PC with my Macbook
    That has to be set first on the PC.

  • Crashing When Saving Photoshop  File Over Network

    Photoshop & InDesign CS3 crashes whenever I try to save a file over the network to a another shared Mac Pro computer. Another Mac Pro on the network can save to the shared computer without a problem.
    SPECIFICS
    - Three Macs and a 3 PC's on Ethernet network
    -Problem started after upgrading to Leopard
    - I have tried reinstalling the entire Creative Suite without Version Cue
    - Tried deleting the com.adobe.mediabrowser.p.ist and Photoshop.plist preferences.
    - If I create a new file on my computer and then immediately save it, it usually does not crash on the first save. But after I do a few things to the file and then try to save again, it hangs up giving me the spinning pinwheel with the message in the Force Quit dialog window that Photoshop is not responding.
    +- I am unable to force quiet Photoshop; I have to do a hard reboot.+
    Adobe tech support believes it is a network problem, any ideas what might be causing the problem?
    Are there any know issues with Leopard and CS 3 with certain network configurations?

    I have experienced issues with saving photoshop files over a network since upgrading to 10.5.3
    This is a major issue, and one that apple seems quite about.
    See related response on Adobe.com
    http://kb.adobe.com/selfservice/viewContent.do?externalId=kb403815&sliceId=2

  • How to send simple file over network!

    Hi!!
    can any body guide me how to send a simple txt and other files (not media files) over net!
    what would i have to do to do so ?
    do i have to understand the files headers and got to use udp protocols if yes then plz tell me how
    Thank you!

    Well thanks for informing me...
    But what if i want to send a media file using udp not rtp protocol then should i have to so the same ?
    any one going to help me in other way ?
    Thank you !

  • Unable to access shared files over network after period of time.

    First off, I don't think that this issue is related to our router, but I have been searching for a fix and can not find one. We have a WRT54GS. Now, on to our issue:
    At my work, we have a small network with computers sharing files between the others. I have attached a network diagram to help explain this better.
    Our Win7 machine is our main computer that shares an external hard drive with much information that the other computers need to access. What we have noticed is either after a sleep, or even a period of time of say, 2 hours, those files are no longer able to be accessed. The Win7 machine is still sharing them, but the WinXP machines are unable to access them anymore and my Mac can see the computer is unable to connect to the folders. I have gone and attempted to get some help over at Microsofts site but that was a fail. Here is the link to the forum post there. http://social.answers.microsoft.com/Forums/en-US/w7network/thread/f0a2e8d6-f75a-41d7-a280-c6f3adbffa...
    A member there gave me this:
    The Network connection is probably not resuming after sleep. 
    First try this, http://www.ezlan.net/Win7/power_save_win7.jpg
    It is in the Network Connection Properties under the Network card configuration.
    If it already checked this way, or does not work after checking, the Network card has to be taken out of the computer's Power Saving loop, and stay on all the time.
    Otherwise, Updating the Card with the latest OEM drivers (downloaded from the computer's support site) might help too.
    On a rare occasions, some cards might be "Quirky" in this regards and need to be replaced.
    --I would like to add that this DOESN'T ONLY happen after sleep, it also happens after a time of being used.
    I attempted those and no luck. This problem is still occurring and the only way we can fix it is by restarting the Win7 machine. But even if it is being used, we have no idea when those files are unable to be accessed.
    *I will add that the Win7 machine is still able to access the other computers when this problem occurs if that helps.
    **The Win7 machine is a Dell T3500 running Windows 7 64bit. I can provide specific hardware if needed. The drivers are all up to date as of yesterday.
    ***So upon looking in the Windows XP machine, both of the folders from the Win7 machine disappear once this problem occurs in the My Network Places folder. And one folder is on the internal drive, one is on external. The computers are in this situation now where I am unable to access them. The Win7 machine can read and write from the other computers, but the other computers can even see the Win7 Machine.
    ****All the connections are wired and are not using the wireless.
    Thanks for any help that anyone may have for me!
    Steve
    Network Map > http://scubasblog.com/network.jpg
    Dell Support Forum with same issue I posted >> http://en.community.dell.com/support-forums/network-internet-wireless/f/3324/p/19337620/19716797.asp...

    It sounds like there is incompatibility issue with XP and Win7. To isolate this, do you have another Win7 machine? Try to add it to the network and check if the shared drives are accessible after sleep. If you don't have another computer, try virtual machine and create a Win7 system.
    Update your LAN card driver from the manufacturer's site. Don't use the driver from windows update.
    Lastly, does this happen to your XP machines? Like, one of the XP machine sharing a folder and falls asleep. When it wakes up, does Win7 machine can still access the shared folder?

  • Final Cut doesn't playback when copy any files over network

    First, i want say a thanks for all guys who help us here. Thank you very much. Much appreciate.
    Now, problem...
    My Final Cut works perfect sice a starded used 2005, never i have a one problem.
    But last week i discover this:
    When a copy any files between macs over a network the final cut doesn`t play in the sequence. nothing happening. but if i stop copy in the finder, it ok, everything back normal again.
    I try using a project over a network and its perfect, fine.
    only if i copy anything in the finder and final cut doesnt play.
    Guys, anyone have this problem? Its normal?
    I dont know, i try many this before i post here and nothing works.
    Ps.: I have two imac i7 and this two have same problem.

    I hope i understand you right.
    when you copy a file from one network to another sometimes the file paths are lost. Like if you have a drive called FCP HDD on one cpu and FCP HDD3 on another. The original path is associated to the copied files on FCP HDD drive and not the FCP HDD3 drive so a path would be lost there.
    If you are connected via gigabyte ethernet cable and the imacs are synced then there would only be a latency problem as the gigabyte ethernet is slower than sata and FW 400 or 800.
    If you are just coping the source media (meaning the files you captured from the cam) then all of your paths will be new based on the place you copied them too.
    so if i have a project like 'My Commercial' and that is the name of the project file then it is it own project. The media within that project is associated to which ever drive you put it on.
    If i move the project to another computer then the media is not there.
    Why? Because the project is looking for the name of the original drive which may not exist on the imac you moved the project too. Unless you have a server.
    Also, Even if you do move the media files to the drive that IS connected to the new computer the drive is most likely to have a different path for the media.
    What you want is to connect the 2 cpus in a way that allows drive sharing.
    Do you get the red 'Media Offline" error in the timeline?

  • Unable to transfer files over network

    Hi all
    I'm trying to transfer some folders from my MBP to my iMac over a wireless network, but I get a series of 3 error messages when I try it.
    First I get "You may need to enter the name and password for an administrator on this computer to change the item named "(folder name)"". Options given are Stop or Continue.
    Upon pressing Continue I get the message "The item "(folder name)" contains one or more items you do not have permission to read. Do you want to copy the items you are allowed to read?" Same options given.
    Pressing Continue one more time, I see "The operation cannot be completed because you do not have sufficient privileges for some of the items.
    File sharing is on for both computers, and I'm logged in as the main admin user.

    I just came across this same issue this morning with a client. She is the admin on three Macs, and her kids are all standard users. All three Macs have file sharing enabled, etc. Every user BUT her can pull or send files to any other machine (to their own user folder, of course) but she can only PULL. Trying to send a file or change a file on a remote machine fails with these same three messages.
    I tried the trick of resetting a password or resetting the ACL for her user folder while booting from the install disk, etc. but nothing works. I have to believe that at some point in time when she changed her admin password, something "broke" on all three machines. She is given "access" but for some reason is not seen as a admin.
    I'm a bit stumped. I haven't tried the "new UUID" step, but if it's temp at best, probably won't work. What I am thinking of trying next is changing her shortname and directory name, rebooting, logging in as root, creating a new admin user with her old name and moving all of her files. The problem appears to be at the home folder ACL level so I am hoping a new home folder will fix the problem.

  • Copy files over network and preserve original date modified/created

    This problem originally cropped up when importing photos into iphoto. I copied all my pics across the network and stored them locally then imported them into iPhoto. Problem was, any pics that did not have EXIF data were sorted by iPhoto, by date created...which was the date they were copied to the Mac.
    I got around that by trashing the iPhoto Library, then importing the photos over the network. The dates on the pics were correct on the Windows machine till the copy process changed them.
    is there a way to copy across the network and keep all the file attributes as they are on the original..An archive type feature.
    I had thought of RsyncX, but have not used that yet from within the Mac.
    Is there a way from within Finder to copy and keep attributes? or a third party app?
    Neil

    zip the folder with your pictures (control-click on it and choose "compress folder"), copy the zip files to the remote computer and unzip it there. this will preserve the modified and created dates.

  • Acrobat 9 Pro very slow open files over network in Windows 7

    I have installed Acrobat 9 pro on my new PC. It's running Window 7 64bit. I use it for pre-press of high-resolution files for printing. Sometimes the file sizes run into the 100s of MB.The new PC has reasonably high specs, with 6Gb of RAM and a 2.8Ghz Quad core i7 CPU and gigabit networking.
    Opening them when on the local hard disk is reasonably fast. For example a multi-page 400Mb file starts drawing the first page withing 3 seconds. But opening the same file when it's on the server of our gigibit network generates a very long pause. The application locks up and dispays a "not responding" message for 2-3 minutes. The bigger the file, the longer the pause. It doesn't completely crash -- eventually it starts to draw the pages and I can work as normal.
    I used to have Acrobat 9 pro on my old XP PC which was a cheap low-end machine when bought 3 years ago. (has on-board shared RAM graphics card and only 1Gb of RAM). But what grieves me the most, is this slow old machine will open the same 400Mb file off the server so much faster than my expensive new machine. There is no lock up and it begins drawing the first page after only approx 5 seconds.
    The problem doesn't seem to be simply related to slow network speed. I can copy the entire 400Mb file from the server to my hard disk in only 12 seconds. The old PC is actually slightly slower copying to/from the network. If the application was for some reason copying the entire file into memory or to a local cache, this should still only generate an extra 12 second delay -- not 3 whole minutes.
    Adobe Reader 9 doesn't have the problem. I can open the 400Mb file off the network on either my new or old machine within seconds.
    Acrobat 9 Pro doesn't have the problem on an old G5 mac either. It's somewhat slower than my old PC but will begin drawing the first page after a few seconds,
    So what exactly is Acrobat doing for those 2-3 minutes?
    I have already tried:
    1. changing network ports/cables.
    2. disabling anti-virus software
    3. disabling "remote differential compression"
    4. Patching Acrobat 9 to 9.2
    5. Files located on Windows servers and Mac Xserves.
    Not improvements from any of these.

    I think I have isolated the source of this problem. It's the Pitstop Professional 9 plug in. I un-installed this, and everything opens quicker than greased lightning. I re-installed it and it's back to slowsville.
    Unfortunately Pitstop is essential to my workflow.
    Until recently I did my pre-press on a Mac G5 with Acrobat Pro 7 and Pitstop 6.5. I never had this problem with slow file opening. But it seems that the delays would occur when I used the plug-in with large complex files.. So it would open files as fast as you'd expect from an elderly machine. But starting to use Pitstop would result in a prolonged period of staring at a spinning beachball.
    I wonder is there any way to stop the Pitstop plug-in from initializing until it is used? So the plug-in stays inert until you select the tool from from the menus.

  • Bridge Doesn't Like Index Color .gif Files Over Networks?

    It's been a nightmare trying to navigate network folders with Bridge CS3 (Mac 10.5.3, 2x2.8GHz, 4GB ram) It's not uncommon to have to restart Bridge numerous times daily (tried all the fixes mentioned on these threads, and updated to the latest version of Bridge)
    I finally noticed it stops and gives me the spinning wheel every time it encounters a .gif file, so I removed those files from the folder, converted them to RGB and re-saved them as .jpg from Photoshop and bingo! Bridge cached the folder quickly and without incident.
    Is this issue documented anywhere? Is there any way to tell Bridge to just ignore .gif files?

    Just an update,
    I installed Apple's latest patch and Bridge is much more stable, but will still lock up anytime it encounters a network folder with .gif or .png files.
    But at least now I know how to avoid this issue. Maybe future versions of Bridge will allow users to select certain file types to ignore when caching.
    [checkbox] Ignore Files of this type: [options]

Maybe you are looking for