ServerSocket.accept (modification of file locks)

Hello
I'm doing a sync files system, which is based on several clients and a server. I'm having a problem with the ServerSocket.accept () method on the client. The source code for the client is:
while(true)
{
                servsock.setSoTimeout(500);
              try{
               Socket sock1 = servsock.accept();
                  .
                  Recieve file
                  .
                  .
            }
                  catch(SocketTimeoutException e){ 
                  }

          table = scan.scan(); // method for checking if any changes in the folder has occurred 
          sendTable = sync.checkTable(table);
          if (!sendTable.isEmpty()) {
                  send the file!
          }
}
but it seems that sock1 = servsock.accept () method, it is impossible to delete or modify files and folders.
The error I get is:
"Error deleting file or folder.
Cannot delete the folder xxxxxx: it is used by another person or program.
Close all programs that might be using the file and try again. »

If I delete the code for the reception of files on the client, I am able to modify and delete files and folders that I want to, on both the server and client. But then the customer is not able to check for any changes to the file. If anyone knows why the method of. accept() lock for editing file and how can I fix?

I downloaded the source code at rapidshare
Source code for the client:
customer08-10 http://rapidshare.com/files/423860591/FileSync_-- 2010.rar
Source code of the server:
customer08-10 http://rapidshare.com/files/423860591/FileSync_-- 2010.rar

Published by: user1007061 on 2010-10-09 00:07

Normally, you apply for a client OR a server. Rarely, you need to do both, because it increases the complexity for very little value.
For your use case I suggest use a JMS topic to broadcast the changes to files to all customers. This way you have a broker with many customers whichc all send and listen to updates.

Another approach would be to use a control system like subversion which allows to check in the changes (and keep a history) and script for a version update files regularly. You can do all this without writing any Java code at all.

However, for your specific problem. I suspect that you not close your file before trying to write in the file again. that is, you are locking your own file. In any case, as others have said, the use of sockets NOT to lock your files are will do everything for them somehow.

Tags: Java

Similar Questions

  • Cannot access files locked with access TrueSuite Manager

    I have files with Access Manager TrueSuite locked. My Windows bug and now I cannot access these files locked.
    When you try to unlock, I get the error and I can not read these documents.

    Thank you.
    Excuse my bad English.

    I found this document:

    Useful information about the file protection with AuthenTec fingerprint software
    http://APS2.toshiba-tro.de/KB0/TSB9C02RC0001R01.htm

    Eventually, you will not be able to unprotect the files again
    But try this backup data to the external HARD drive or somewhere else.
    Then reinstall this software and import data from external source.
    Then try to unlock this new

  • After cancellation of Vista all the files locked by TrueSuite

    A while back, I drove back into Windows Vista to an earlier date and thus all my files locked by TrueSuite became corrupted and I can't open them, move, delete, etc.
    I tried to remove it from the command prompt, but that no longer works.

    Is there a way I can remove it?

    Thanks for any help.

    Hello

    Have you tried to delete these files once the TrueSuite has been uninstalled?
    I think that it s worth a try.
    Remove the TrueSuite of the system, reboot the laptop, clean the BONES and the registry using the CCleaner and reboot the laptop again.
    Then check if the locked files can be deleted again.

    Greetings

  • Why do I get a file lock unexpected error every time I try to open excel 2007

    try to open and work in excel 2007 and receive the following error message, the file is taking also etremely long to open, save, and close.

    file location: Server

    file size: 214 mb

    the file is a shared workbook

    error message

    unexpected by file locking.  You can replace this file lock, or continue without doing so.  If you continue without overriding this lock, you will not be able to save this file, but you can use the file save as to save your work in a separate file. Dou you want to continue?

    Excel forums can be found here:
    http://answers.Microsoft.com/en-us/Office/Forum/Excel

  • file locking program

    can you suggest a program of microsoft authorized file locking?

    HI Jeffrey,.

    Microsoft has no any program to lock the single files, but you can protect your files using BitLocker Drive encryption.

    You can use the drive encryption BitLocker to protect all files stored on the drive Windows is installed on (operating system drive) and on data drives (for example, internal hard drives). You can use BitLocker to go to help protect all files stored on removable data drives (such as external hard drives or USB flash drives).

    http://Windows.Microsoft.com/en-in/Windows7/help-protect-your-files-using-BitLocker-Drive-encryption

    For file locking program more, I suggest you use your favorite search engine and check if that helps.

    Warning: using third-party software, including hardware drivers can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the use of third-party software can be solved. Software using third party is at your own risk.

    It will be useful. If you need help, please after return. We will be happy to help you.

  • Cannot delete files locked in the temp folder

    I emptied regularly delete all files in the temp via the function folder in the Tools menu of IE9 and also by searching on folder and deleting the contents of the temporary Local AppData file in the users folder.

    Ten days ago, I found there are some files in the folder temporary AppData that were locked and could not be removed. This only happens in a user account, and this isn't an administrator account. Opening of properties on any of the files by checking the Security tab, I find I am wierdly the sole owner of the file, but have limited permissions. I tried to change the permissions to get total control and then remove the file, but that did not work, nor has anything else I could think of. This included the stop of all open applications and disconnects all users.

    Other file properties:

    -Open with "Windows Shell Commo" - little matter that is.

    -Similar names to ~ DF38C18158B32C1039. TMP

    -Attributes: ATI

    -The size is small (512 bytes, for example)

    -No previous versions

    Normally the files in this folder have names like this except without the ~.

    After having in vain tried everything I could think of to delete these files, I downloaded Revo Uninstaller, who managed to remove all the files locked in the record at the time.  However, the problem resurfaced shortly after and this time Revo Uninstaller did not work.

    I spent a few days of research on the net and try different options without success until I stumbled on a recommendation to go into Control Panel, search for Java, open its settings menu and refuse authorisation for Java to back up the data on my computer.  It worked - I went back in the folder, the files were no longer locked, I was able to remove them as I usually do and I had no other problems with the locked files. Until yesterday.

    I double-checked the settings of Java to ensure that authorization still denied to save data on my computer. I don't remember now if I set permission to refuse when I checked again. I tried then to Revo Uninstaller again, but he failed again to remove these files locked. I noticed today that the date for all files is last July 15.  It seems (so far) no new files have been generated, but I still cannot delete locked files 51 of my computer.  My biggest concern, obviously, is security.  I don't want to locked files including origins, functions and activities that I do nothing on my computer, especially if I'm unable to remove them.

    I want to know how to remove these files, what caused do them appear in the first place and how to prevent them from happening again.

    Thank you!

    Thanks for this suggestion, Oberwald. It came a little too late, however.  Finally, it occurred to me to try my anti-virus software file shredder function and he managed to remove the locked files.

    I believe now these locked files were likely due to some kind of malware - after shredding, my desktop Recycle bin flashed repeatedly icon when I shut down the computer. Also, after have logged you in today, I find everything runs much faster and no sign of keylogging.  Seem to be back to normal.

    I was able to save the link and it will try in the future if necessary.

    Thanks again!

  • Layout file lock error when publishing.

    Hello Experts,

    I am getting error on the destination server when published below: -.

    [2015-06-13 00:04:31, MYT 003] [ERROR] [pool-13-thread-1] file locking [fatwire.logging.cs.filelock] Unexpected failure

    1. Com FutureTense.Util.NioFileLock$ NioFileLockException: failure low level construction in FileLock RandomAccessFile constructor. It has been attempted in total 400 times, wait 25 between two attempts. [File: opt/oracle/Sharedv2/clustersync/genIDLockFile.ftlock]

    to com FutureTense.Util.NioFileLock$ LockFile.constructRandomAccessFile (NioFileLock.java:339)

    to com FutureTense.Util.NioFileLock$ LockFile. < init > (NioFileLock.java:272)

    to com FutureTense.Util.NioFileLock$ LockFile. < init > (NioFileLock.java:245)

    to com FutureTense.Util.NioFileLock._lockFile(NioFileLock.java:64)

    to com FutureTense.Util.NioFileLock.lockFile(NioFileLock.java:33)

    to com FutureTense.Util.ftFileLock.lockFileName(ftFileLock.java:91)

    at COM.FutureTense.Common.SysIdGen._lockID (SysIdGen.java:233)

    at COM.FutureTense.Common.SysIdGen._allocate_logic (SysIdGen.java:256)

    to COM.FutureTense.Common.SysIdGen.access$ 300 (SysIdGen.java:32)

    to COM.FutureTense.Common.SysIdGen$ AllocateRange$ 1.execute(SysIdGen.java:344)

    at com.fatwire.cs.core.db.NestedTransactionBlock.execute(NestedTransactionBlock.java:189)

    to COM.FutureTense.Common.SysIdGen$ AllocateRange.call (SysIdGen.java:347)

    to COM.FutureTense.Common.SysIdGen$ AllocateRange.call (SysIdGen.java:326)

    to java.util.concurrent.FutureTask$ Sync.innerRun (FutureTask.java:303)

    at java.util.concurrent.FutureTask.run(FutureTask.java:138)

    to java.util.concurrent.ThreadPoolExecutor$ Worker.runTask (ThreadPoolExecutor.java:886)

    to java.util.concurrent.ThreadPoolExecutor$ Worker.run (ThreadPoolExecutor.java:908)

    at java.lang.Thread.run(Thread.java:662)

    Due to: java.io.FileNotFoundException: /opt/oracle/Sharedv2/clustersync/genIDLockFile.ftlock (Permission denied)

    at java.io.RandomAccessFile.open (Native Method)

    in java.io.RandomAccessFile. < init > (RandomAccessFile.java:216)

    to com FutureTense.Util.NioFileLock$ LockFile.constructRandomAccessFile (NioFileLock.java:312)

    ... more than 17


    Can any body tell me what could be the reason for this.



    Kind regards

    NJ

    Hello NJ,.

    It looks like the file /opt/oracle/Sharedv2/clustersync/genIDLockFile.ftlock or possibly the directory/opt/oracle/Sharedv2/clustersync / is not writeable by the appserver.

    Kind regards

    Stephan.

  • using script files locked

    Often enough I get the locked files and I have 32 guests in my cluster to find the lock I have generally

    will be executed vmkfstools d on the flat file to reveal the host mac locking.

    Lock [type offset 10 c 00001 79308800 v 9545, hb offset 4063232]

    GEN 383, mode 2, owner 00000000-00000000-0000-000000000000 mtime 26534301

    [Num 3 gblnum 0 gblgen 0 gblbrk 0]

    Owner [0] HB RO offset 54d3ab21 3469312-8e99bc6c-6190 -6cc2172a3340

    Owner [1] HB RO offset 54d3bee6 3764224-c3760cb4-f4a6 -9cb65492e358

    Owner [2] HB RO offset 3567616 54da4e83-ce3f7196 - 3 c 91 -984be1000bea

    I then take off the script depending on whether I won somebody the net and plug in my mac to the desired format and this reveals my hostname.

    to connect-viserver VC

    #Enter the file locked cluster is in

    $cluster = Read-Host "enter Cluster."

    #Enter MAC address of host (format 00:00:00:00:00:00)

    $MAC = Read-Host "Enter desired MAC (format 00:00:00:00:00:00).

    Get-cluster $cluster | Get-vmhost | Get-VMHostNetworkAdapter | where {$_.} Mac-match "$MAC"} | Select-object VMHost, MAC, IP, name, BitRatePerSec. FT - autosize

    disconnect viserver VC-confirm: $false

    The problem is I would just to copy and paste a mastic instead of having to add the: in the appropriate places (ease of use, lazy, etc...)

    I found this script to perform the conversion

    $mac = "001122334455".

    $mac = $mac.insert(3,":")

    $mac = $mac.insert(6,":")

    $mac = $mac.insert(9,":")

    $mac = $mac.insert(12,":")

    $mac = $mac.insert(15,":")


    write-host "mac address-table address $mac sh.

    but I have no ideal how to combine the two.

    Can someone who knows really how script and not only steal from the net help out me?

    Thank you

    -Glenn

    Hi Glenn,.

    Here you go...

    connect-viserver VC
    #Enter which cluster the locked file is within
    $cluster = Read-Host "Enter Cluster"
    #Enter MAC Address of host
    $mac = Read-Host "Enter desired MAC (AABBCCXXYYZZ format)"
    $mac = $mac.insert(2,":")
    $mac = $mac.insert(5,":")
    $mac = $mac.insert(8,":")
    $mac = $mac.insert(11,":")
    $mac = $mac.insert(14,":")
    get-cluster $cluster | get-vmhost | Get-VMHostNetworkAdapter | where {$_.Mac -match "$MAC" } | select-object VMHost, Name, MAC, IP, BitRatePerSec | ft -autosize
    disconnect-viserver VC -confirm:$false
    

    Note that I've changed numbers based on insertion so that it places ":" in the right place. Give it a try and then how it's happening.

  • Photoshop elements 11 will not accept my NEF files

    After that reinstallation of EP 11 (a re-setup Win 7) will not accept my NEF files.

    I had no problems before.

    My camera is a Nikon D7100.

    I tried to update Camera Raw, but it's always the same version: 7.1.0.354.

    I tried to uninstall everything except Win 7 with no luck.

    Yes - but I solved the problem, thanks anway

  • When I import my .wav and my .m2V files still accepts the .wav file but does not load the .m2V file.  I created movie DVD 5 discs - still accepted the .wav and for the four remaining groups .m2V files and created 4 DVD discs for

    When I import my .wav and my .m2V files still accepts the .wav file but does not load the .m2V file. I created movie DVD 5 discs - still accepted the .wav and for the four remaining groups .m2V files and created 4 DVD discs for these files. What can I do to be free from this error?

    OSstatus = error-37

    Note that this a Mac operating system error.

    http://forums.CreativeCOW.NET/thread/145/865447

    Error when importing the file: slash or other character in file name

    http://forums.Adobe.com/message/3729601

    The build error: slash or other character in file name

    http://forums.CreativeCOW.NET/thread/145/868994

    The build error: complete startup disk

  • PES 10 still does not accept a cr2 file when well even I downloaded dng converter... Do I need an another Photoshop?

    PSE will not accept a cr2 file. Why is this?

    You batch convert a CR2 file folder and use the DNG files in PSE10

    You can convert an entire folder of images raw with a single click. See this quick video tutorial:

    You Tube click here for the DNG Converter tutorial

  • I have redownloaded my CS5 Photoshop and Camera Raw will not accept my RAW files or Adobe Bridge displays the display of the image of these files. A message appears saying: it does not support this camera.  I have a Nikon 5100 digital SLR.  He has always

    I have redownloaded my CS5 Photoshop and Camera Raw will not accept my RAW files or Adobe Bridge displays the display of the image of these files. A message appears saying: it does not support this camera.  I have a Nikon 5100 digital SLR.  He has always displayed them in the past.  How do I get to view these photos in Bridge, then open them in RAW?

    Your Nikon 5100 requires a minimum of 6.4 ACR.

    The ACR, which is installed with CS5 default is 6.0.

    You must update your ACR to the latest version available for CS5 - ACR 6.7

  • Host - HA Cluster failure &amp; file locking

    Hello

    In a HA cluster, if the failure of a host (loses power or something similar) how are the locks on files on a virtual machine that was running this particular host published so that another host in the cluster HA can start? I know that if a host finds that as isolated, it releases the file locks, but what happens in case of failure?

    Thank you

    Steve

    Blockage in a shared storage have a waiting period of I think 15 seconds. Direct receipt is refreshing the lock so the other guests cannot claim locked object. When the host fails the lock expires and can be requested by another host in a cluster.

  • Can I work around a file locked?

    Barrie Scott , may 8, 2016 14:04

    I have several locked files that I want to edit, but when I go to get information, the locked box is grayed out and I can't seem to him. If I go to the bottom of the Get Info and unlock the padlock, it makes no difference. I am the administrator, but it seems that I do not have access. It says I have a personalized access. What should do?

    I have not received any response to the foregoing. Is there a way to bypass the blocking on the files?

    OX 10.10.5 Yosemite.

    Pages ' 08 v.3.0.3

    Barrie Scott wrote:

    Is there a way to bypass the blocking on the files?

    Launch the Terminal and copy and paste the following at the prompt...

    chflags-r nouchg

    Then drag the file that you want to unlock in your terminal window, and then press the return key.

  • Bootcamp does not accept the iso file

    I try my macbook pro for windows 8.1 El Capitan Bootcamp and I have the iso file you downloaded here:https://www.microsoft.com/en-us/software-download/windows8ISO but Deputy bootcamps does not accept it. It is said that the iso file is not windows 7 or higher. I tried to use windows iso 10 too, but it says the same thing. Can someone help me pleas with this error. Thank you.

    You can check the MD5sum of your ISO 64 bit Windows 8.1? Use the command highlighted in OS x Terminal in the directory where your ISO.

    OpenSSL md5 Win8.1_English_x64.iso

    MD5 (WIN8.1_English_x64. ISO) = e0d4594e56c0545d379340e0db9519a5

Maybe you are looking for