When client send file  connection with server close

please help me.
i want to transfer a file via server - client model.
Client send the file, server receive it.
Then when i send a msg from server to client i have this error:
java.net.SocketException: socket closed
why the socket closed?

client waiting for response. i don't know what to do.
the client code is:
import java.net.*;
import java.io.*;                              
class Client{               
     Socket clientSocket;               
       byte[] byteArray;                    
       BufferedInputStream bis;          
        BufferedOutputStream bos;          
       int in;                                   
       BufferedReader inm = null;
        PrintWriter outm = null;
       public Client(){
         try{
                clientSocket = new Socket("localhost", 9632);
               System.out.println("i am client & connect");
               inm = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
               outm = new PrintWriter(clientSocket.getOutputStream(), true);
               System.out.println("------1--------" +clientSocket.isClosed());
                  outm.println("msg 1: hi");
                  System.out.println("from server__ " +inm.readLine());
                  outm.println("msg 2: now i will send you a file");
                  System.out.println("from server__ " +inm.readLine());
                  sendFile();
                 System.out.println("-------2-------" +clientSocket.isClosed());
                  System.out.println("from server__ " +inm.readLine());
         catch(IOException e){
                e.printStackTrace();
       public void sendFile(){
            try{
                 bis = new BufferedInputStream(new FileInputStream("encryptAtmMsg.txt"));
                bos = new BufferedOutputStream(clientSocket.getOutputStream());
                byteArray = new byte[8192];
                while ((in = bis.read(byteArray)) != -1){
                   bos.write(byteArray,0,in);
                    bis.close();
                  bos.close();
           catch(IOException e){
                e.printStackTrace();
       public static void main(String[] args){
         new Client();
}And server code is:
import java.net.*;
import java.io.*;
class Server{
     BufferedInputStream bis;
       BufferedOutputStream bos;
       byte[] data;
       Socket socket;
       ServerSocket serverSocket;
       int in;
        BufferedReader inm = null;
        PrintWriter outm = null;
       public Server(){
         try{
                serverSocket = new ServerSocket(9632);
                System.out.println("i am server & listening...");
               socket = serverSocket.accept();
                 System.out.println("a client connect");
               System.out.println("------1--------" +socket.isClosed());
                inm = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                outm = new PrintWriter(socket.getOutputStream(), true);
               System.out.println("from client: " +inm.readLine());
                 outm.println("ack 1: hi....");
                 System.out.println("from client: " +inm.readLine());
                 outm.println("ack 2: ok....");
                receiveFile();
                  System.out.println("------2--------" +socket.isClosed());
               outm.println("ack 3: take the file");
         catch (IOException e){
              e.printStackTrace();
     public void receiveFile(){
          try{
              byte[] receivedData = new byte[8192];
             bis = new BufferedInputStream(socket.getInputStream());
               bos = new BufferedOutputStream(new FileOutputStream("encryptAtmMsg22.txt"));
             while ((in = bis.read(receivedData)) != -1){
                   bos.write(receivedData,0,in);
             bos.close();
         catch (IOException e){
              e.printStackTrace();
     public static void main(String[] args){
         new Server();
}any idea pls

Similar Messages

  • After downloading InCopy I click on the downloaded file to install, but the process stops when trying to connect with server and doesn't carry on.

    After downloading InCopy I click on the downloaded file to install, but the process stops when trying to connect with server and doesn't carry on. Can you please help?
    Thanks,

    Agathe.texier which copy of InCopy are you downloading and installing?  Do you receive any specific error messages?  Finally what operating system are you using?

  • Client Not connected with Server

    Hi Experts
    I upgraded my Patch level from 9.0 PL8 to PL9.  Server and Clients are installed and it is working fine but one PC not connected with Server.  While I Connect SAP in landscape server selection Page Port Number shown as 40000 instead of 30000.   I changed Port No from 40000 to 30000 the error Message came as  [message 60070-99999987}.  I attached the Screen shot in this discussion.
    Please help me to resolve this issue.
    With Regards
    Balaji Sampath

    I have same problem and this is the solution
    Go to the directory C:\Program Files (x86)\SAP\SAP Business One\Conf
    Copy the file b1-current-user.xml and put it aside
    Go to the directory %USERPROFILE%\Local Settings\Application Data\SAP\SAP Business One
    Check the file b1-current-user.xml which is likely empty or wrong strings
    Rename the b1-current-user.xml file for backup
    Move the copied file into the directory.
    License server name asked every time on login

  • Hi there, I am trying to connect to my server at work from home using a vpn connection. It connects fine and the time ticks along, but when i click go - connect to server, it comes up with connection failed. Please help!

    Hi there, I am trying to connect to my server at work from home using a vpn connection. It connects fine and the time ticks along, but when i click go - connect to server, it comes up with connection failed. Please help!

    ... when i click go - connect to server, it comes up with connection failed.
    If you're trying to connect to a Bonjour server on the remote network, that won't work over a layer 3 VPN. Use something like Hamachi or one of the SSH-tunnelling Bonjour proxy apps for that.

  • When I send an email with a photoshop file attached, the recipient receives it "flattened". How do I change this?

    when I send an email with a photoshop file attached, the recipient receives it "flattened". How do I change this?

    I've sent psd files to various people without issues, however you might want to try something like www.filedropper.com to make sure it's not that they can't open your version of psd file.
    You may also want to zip the file using the built in archiving software, simply right click (or control click) the file and choose Compress ....,  then you can email it to the person as a compressed archive.  That should preserve all the aspects of the file properly without any modifications.

  • I suddenly can\'t send photos out to be printed. "Can\'t connect with server"

    I suddenly can't send my photos out to be printe. "Can't connect with server"

    Hi,
    Please refer the link below to troubleshoot the issue.
    http://h10025.www1.hp.com/ewfrf/wc/document?docname=c02754298&tmp_task=solveCategory&cc=us&dlc=en&la...
    Although I am an HP employee, I am speaking for myself and not for HP.
    --Say "Thanks" by clicking the Kudos Star in the post that helped you.
    --Please mark the post that solves your problem as "Accepted Solution"

  • A pop-up window advising of software update for Firefox appears and does not connect with server

    The window suggests strongly that I update software but when I attempt to update it does nothing but try to connect with server and never does

    * http://kb.mozillazine.org/Software_Update (Software Update not working properly)
    Remove the files in the updates and updates\0 folder.
    You may need to delete active-update.xml and updates.xml as well if present.<br />
    XP:
    C:\Documents and Settings\&lt;user&gt;\Local Settings\Application Data\Mozilla\Firefox\Mozilla Firefox\updates
    (%USERPROFILE%\Local Settings\Application Data\Mozilla\Firefox\Mozilla Firefox)
    If you have problems with updating then best is to download the full version and uninstall the currently installed version.
    You may need to remove the Firefox program folder to do a clean install of the new version.
    Do a clean (re-)install:
    Download a fresh Firefox copy and save the file to the desktop.
    * Firefox 4.0.x: http://www.mozilla.com/en-US/firefox/all.html
    * Uninstall your current Firefox version and remove the Firefox program folder before installing that copy of the Firefox installer.
    * Do not remove personal data if you uninstall the current version.
    * It is important to delete the Firefox program folder to remove all the files and make sure that there are no problems with files that were leftover after uninstalling.
    Your bookmarks and other profile data are stored elsewhere in the [http://kb.mozillazine.org/Profile_folder_-_Firefox Firefox Profile Folder] and won't be affected by a reinstall, but make sure that you do not select to remove personal data if you uninstall Firefox.

  • When I send an email with an attachment larger than 1 MB in iMail, the email takes forever to be sent.

    When I send an email with an attachment larger than 1 MB from iMail, the email gets suck in the sent folder.  This happens no matter if I am using wireless or using an ethernet connection. 

    Many email programs, including Mail, will send data up to a certain size.
    The good new - there are some solutions. You can compress the file and make the email much faster to send; you can download a free application like Compress, which also allows you to uncompress. Or, you can send your email via your webmail connection (your ISP, like ATT); if you manage your email through your desktop computer, the email should be sent just fine.
    Apple Mail is designed for smaller documents, well under 1mb.

  • ERROR http: 5: Unable to initialize ssl connection with server, aborting co

    HI EXPERTS,
    one of my database give me below error when i start its dbconsole. and after failure it give me meassge
    TZ set to Asia/Karachi
    Oracle Enterprise Manager 10g Database Control Release 10.2.0.4.0
    Copyright (c) 1996, 2007 Oracle Corporation. All rights reserved.
    https://test:5500/em/console/aboutApplication
    Starting Oracle Enterprise Manager 10g Database Control ..............................................................
    ........ failed.
    Logs are generated in directory /u01/oracle/product/10.2/cnichol_cpuplt/sysman/log
    and in trace file name "emdctl.trc" below error is logged.
    ERROR http: 5: Unable to initialize ssl connection with server, aborting connection attempt
    ERROR ssl: nzos_Handshake failed, ret=29024
    and trace file named "emagent.trc" give below error
    2010-10-04 19:12:25 Thread-88238992 ERROR http: 11: Unable to initialize ssl connection with server, aborting connection attempt
    2010-10-04 19:12:25 Thread-88238992 ERROR pingManager: nmepm_pingReposURL: Cannot connect to https://test:5500/em/upload/: retStatus=-1
    2010-10-04 19:12:38 Thread-88238992 ERROR upload: Error in uploadXMLFiles. Trying again in 300.00 seconds.
    dbconosle URL is
    https://test:5500/em/console/aboutApplication
    Operating system is Redhat linux AS 5.3
    what is the possible cause of this failure any one can guide me.
    thanx in Advance
    regards,
    Edited by: AMIABU on Oct 4, 2010 7:28 AM

    oracle@bcm-laptop:~$ emctl
    Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0
    Copyright (c) 1996, 2009 Oracle Corporation.  All rights reserved.
       Oracle Enterprise Manager 10g Database Control commands:
            emctl start | stop dbconsole
            emctl status | secure | setpasswd dbconsole
            emctl config dbconsole -heap_size <size_value> -max_perm_size <size_value>
           emctl status agent
           emctl status agent -secure [-omsurl <http://<oms-hostname>:<oms-unsecure-port>/em/*>]
           emctl getversion
           emctl reload | upload | clearstate | getversion agent
           emctl reload agent dynamicproperties [<Target_name>:<Target_Type>]....
           emctl config agent <options>
           emctl config agent updateTZ
           emctl config agent getTZ
           emctl resetTZ agent
           emctl config agent credentials [<Target_name>[:<Target_Type>]]
           emctl gensudoprops
           emctl clearsudoprops
    Blackout Usage :
           emctl start blackout <Blackoutname> [-nodeLevel] [<Target_name>[:<Target_Type>]].... [-d <Duration>]
           emctl stop blackout <Blackoutname>
           emctl status blackout [<Target_name>[:<Target_Type>]]....
    The following are valid options for blackouts
    <Target_name:Target_type> defaults to local node target if not specified.
    If -nodeLevel is specified after <Blackoutname>,the blackout will be applied to all targets and any target list that follows will be ignored.
    Duration is specified in [days] hh:mm
            emctl getemhome
            emctl ilint
    Em Key Commands Usage :
    emctl config emkey -emkeyfile <emkey.ora path> [-force] [-sysman_pwd <sysman password>]
    emctl config emkey -emkey [-emkeyfile <emkey.ora path>] [-force] [-sysman_pwd <sysman password>]
    emctl config emkey -repos [-emkeyfile <emkey.ora path>] [-force] [-sysman_pwd <sysman password>]
    emctl config emkey -remove_from_repos [-sysman_pwd <sysman password>]
    emctl config emkey -copy_to_repos [-sysman_pwd <sysman password>]
    emctl status emkey [-sysman_pwd <sysman password>]
    Secure DBConsole Usage :
    emctl secure dbconsole -sysman_pwd <sysman password> [-passwd_file <abs file loc>]
         [-host <slb hostname>] [-sid <service name>] [-reset] [-secure_port <secure_port>]
         [-root_dc <root_dc>] [-root_country <root_country>] [-root_state <root_state>] [-root_loc <root_loc>]
         [-root_org <root_org>] [-root_unit <root_unit>] [-root_email <root_email>]
         [-wallet <wallet loc>] [-wallet_pwd <wallet pwd>] [-trust_certs_loc <certs loc>]
    emctl secure status dbconsole
    Register Targettype Usage :
    emctl register oms targettype [-o <Output filename>] <XML filename> <rep user> <rep passwd> <rep host> <rep port> <rep sid> OR
    emctl register oms targettype [-o <Output filename>] <XML filename> <rep user> <rep passwd> <rep connect descriptor>

  • I cannot create a new business catalyst site with Dreamweaver CC 2014. The error message states that Dreamweaver cannot connect with server, try again later. How can I fix this problem?

    I cannot create a new Business Catalyst site with Dreamweaver CC 2014 (Mac). The error message states that Dreamweaver cannot connect with server, try again later. In addition, I am also unable to load remotely a previously created Business Catalyst site as it says there is something wrong with my username or password. However when I put my password in and press test connection, it says it has connected successfully. What is going wrong and how can I fix this problem?
    Thanks

    Hi Ozy08,
    Can you try the solutions mentioned in Re: Can't Login to Business Catalyst within Dreamweaver CS6?
    If you still have problems, and you have a purchased version of DW CC, send me your Adobe ID, location, and contact details over a private message. Click my picture and use the message option.
    Thanks,
    Preran

  • TS3988 iCloud acc is saying that the connection with server is closed & i can't sync my calendars on iPad & iphoe with my Mac

    Cant sync icloud Acc as on Mac its sayin that the connection with Server has been closed to try again later i cant sync my Calanars on iphone or Ipad or send out meeting requests can anyone help me with that
    thanks

    I had a similiar problem, with my multiple devices.  I open iTunes and when all devices were connected I went to the info section on each device.  Under info I checked the sync calandars. Under that I click all calanders. I then did the apply in low right. I then did the sync function and it fixed it for me.  You have to do this for each device.
    I also checked the device (ipad,Iphone) themselves and change the calander selection to NO Catagory.  Hope this helps.

  • Find existing connection with server

    Hi,
    i have used socket programming in java. when i start the server
    program ,i want to know how many clients are already connected with
    particular server Port.
    Is it possible? pls, Tell me

    Hi,
    thank you for you reply. But my need is, while server is running, client can establish the connection with server. just imagine now server has connect with 5 clients. Unfortunately server going down.
    And again i start the server it should listen to already existing client connections automatically.
    i want to establish the connections of existing clients from the server.
    if any body having java code or other ideas for this problem , HELP ME!!

  • Lost connection with server

    For about two days now, the bbm application has refused to launch. It has been writing lost connection with server....can any one please help! It's really urgent

    Hi and Welcome to the Community!
    With a strong carrier network signal (e.g., not merely WiFi), I suggest the following steps, in order, even if they seem redundant to what you have already tried (step should result in a message coming to your BB...please wait for that before proceeding to the next step):
    1) Register HRT
    KB00510 How to register a BlackBerry smartphone with the wireless network
    Please wait for one "registration" message to arrive
    2) Reboot
    Pre-BB10 Devices ONLY. With power ON, remove the back cover and pull out the battery. Wait about a minute then replace the battery and cover. Power up and wait patiently through the long reboot -- ~5 minutes.
    BB10 Devices. Hold the top button down until the counter reaches zero. Wait for the device to be fully shut down (e.g., nothing at all displayed on the screen, no LED lights, etc.). Hold the top button until the red LED is lit. Wait through the full boot-up process. IF this fails, you can attempt the battery-pull method above, but it is normally NOT recommended unless nothing else works.
    See if things have returned to good operation. Like all computing devices, BB's suffer from memory leaks and such...with a hard reboot being the best cure.
    Hopefully that will get things going again for you! If not, then you should contact your mobile service provider for formal support.
    Good luck!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Error message "unable to connect with server. Check wifi connection"

    I started having the error message "unable to connect with server. Check wifi connection" when I attempt to use search function within a certain apps and when I try to download certain magazine (eg. National geographic).  I didn't have this problem with I first started using iPad, and no problems with connectivity when using other apps.  Can anyone help?

    You may not really be connected to your WiFi network.
    Your router may not have given your iPad a valid IP address. Go to Settings > Wifi > your network name and touch the ">" to the right to see the network details. If the IP address starts with 169 or is blank then your router didn't provide an IP address and you won't be able to access the Internet.
    Sometimes the fix can be as simple as restarting your router (remove power for 30 seconds and restart). Next, reset network settings on your iPad (Settings > General > Reset > Reset network settings) and then attempt to connect. In other cases it might be necessary to update the router's firmware with the latest from the manufacturer's support web pages.
    If you need more help please give more details on your network, i.e., your router make, model and version, the wifi security being used (WEP, WPA, WPA2), etc.

  • WHEN I SEND AN EMAIL WITH A MICROSOFT WORD  ATTACHMENT FROM MY DELL COMPUTER TO MY APPLE THE ATTACHMENT COMES AS WIN MAIL. DAT

    WHEN I SEND AN EMAIL WITH A MICROSOFT WORD OR PDF ATTACHMENT TO MY APPLE COMPUTERS OR I PAD IT SHOWS UP AS WIN MAIL.DAT AND I CANNOT OPEN THE FILE, THIS JUST STARTED HAPPENING. PLEASE HELP ME FIND AN ANSWER. JIM

    Please do not type in all caps, that is considered shouting and we can hear   you just fine.
    This is a MS Office issue, I'd suggest taking it up with Microsoft or a MS Office forum.

Maybe you are looking for