File transfer to multiple clients from server socket

I have multiple clients connected to my server socket and I need to copy more than 200mb documents from server to all clients over socket. Can we design the issue considering scalability and performance factor? What I am thinking of we should use thread for transferring file from server to client. But at the same time if we have large number of clients then we can't initialize a thread for each client. I think in this case we should initialize less than 10 threads in the pool as the file size is very large. If we keep number of threads in the pool low then probably we have to read multiple times the large server file (once for each group) which might again be a performance bottleneck. Please pour in your suggestions.

File would be same for an instance only. For example say I have a "SEND File" button & �File Path� text box. In File Path suppose user enters the absolute path of the file and then clicks on Send File button. The responsibility of Send File button would be sending the file mentioned in the "File Path" text box to all connected client. But next time user can choose a different file.

Similar Messages

  • File Transfer b/w Client - Server using JSP

    Hi,
    I need to implement a file transfer between the client and the server using JSP / Beans. The files can be XML Documents, Images (.gif,.jpeg) or even MS Word documents.
    The user has a set directory on his file system where the files are to be saved upon download and retrieved upon upload. This system is similar to a check-in check-out system.
    How do I get a reference to the directory on the users file system and then either save the downloaded files there or retrieve the files that need to be uploaded.
    Thanks
    coffeejava

    The only way you can do this is by using an applet, a jsp page or servlet does not have access to the system that the browser is running on. Furthermore if you were planning on using the html file form object you cannot set a value for that programmatically. It's not allowed for security reasons.

  • How to run the client from server

    HI FRIENDS,
    I HAVE A SMALL PROBLEM WITH MY PROGRAM.I WANTED TO START THE CLIENT FROM SERVER I.E THE CLIENT SHOULD BE EXECUTED AS SOON AS THE SERVER STARTS EXECUTION.SOME OF THEM SAID THAT THIS CAN BE DONE BY USING 'EXEC' COMMAND.BUT I COULDNT.SO PLEASE ANYONE HELP ME IN DOING THIS.
    BYE
    KP

    HI FRIENDS,
    I HAVE A SMALL PROBLEM WITH MY
    MALL PROBLEM WITH MY PROGRAM.I WANTED TO START THE
    CLIENT FROM SERVER I.E THE CLIENT SHOULD BE EXECUTEDCan't be done, unless the server and the client are on the same machine, or you have some other COM object or service set up to allow someone to do this remotely

  • Large file transfer problems over client/server socket

    Hi,
    I wrote a simple chat problem in which I can send files from client to client. The problem is when I send large files over 101 MB the transfer freezes. I do not even get any error mesages in the console. The files I am sending are of any type (Ex mp3, movies, etc...). I am serializing the data into a "byteArray[packetSize]" and sending the file packet by packet until the whole file has been sent, and reconstructed on the other side. The process works perfectly for files smaller than 101MB, but for some reason freezes after that if the file is larger. I have read many forums and there aren't too many solutions out there. I made sure to use the .reset() method to reset my ObjectOutputStream each time I write to it.
    Here's my file sending code:
    byte[] byteArray = new byte[defaultPacketSize];
    numPacketsRequired = Math.ceil(fileSize / defaultPacketSize);
    try {
    int i = 0;
    reader = new FileInputStream(filePath);
    while (reader.available() > 0) {
    if (reader.available() < defaultPacketSize) {
    byte[] lastPacket = new byte[reader.available()];
    reader.read(lastPacket);
    try {
    if (socket == null || output == null) {
    throw new SocketException("socket does not exist");
    output.writeObject(lastPacket);
    output.reset();
    output.writeObject("DONE");
    output.reset();
    output.close();
    socket.close();
    catch (Exception e) {
    System.out.println("Exception ***: " + e);
    output.close();
    socket.close();
    else {
    reader.read(byteArray);
    try {
    if (socket == null || output == null) {
    throw new SocketException("socket does not exist");
    output.writeObject(byteArray);
    output.reset();
    catch (Exception e) {
    System.out.println("Exception ***: " + e);
    output.close();
    socket.close();
    reader.close();
    catch (Exception e) {
    System.out.println("COULD NOT READ PACKET");
    Here's my file receiving code:
    try {
    // The message from the client
    Object streamInput;
    FileOutputStream writer;
    byte[] packet;
    while (true) {
    streamInput = input.readObject();
    if (streamInput instanceof byte[]) {
    packet = (byte[]) streamInput;
    try {
    writer = new FileOutputStream(outputPath, true);
    writer.write(packet); //Storing the bytes on file
    writer.close();
    catch (Exception e) {
    System.out.println("Exception: " + e);
    else if (streamInput.equals("DONE")) {
    socket.close();
    input.close();
    break;
    catch (Exception e) {
    I'm looking for any way I can possibly send large files from client to client without having it freeze. Are there any better file transfer ways other than socket? I don't really want FTP. I think I want to keep it HTTP.
    Any suggestions would be helpful.Thanks!
    Evan

    I've taken a better look a the code you posted, and
    there is one problem with the receiving code. You
    keep repeatedly opening and closing the
    FileOutputStream. This is not going to be efficient
    as the file will keep needing to be positioned to its
    end.Yes sorry I did change that code so that it leaves the file open until completely done writing. Basically I have a progress bar that records how far along in the writing process the client is, and when the progress bar reaches 100%, meaning the file is complete, the file.close() method is invoked. Sorry about that.
    I also ran some memory tests using the "Runtime.getRuntime().totalMemory()", and "Runtime.getRuntime().freeMemory()" methods. I put these methods inside the loop where I read in the file and send it to the client. here's the output:
    Sender's free memory: 704672
    File reader read 51200 bytes of data.
    767548 left to read.
    Sender's runtime memory: 2818048
    Sender's free memory: 702968
    File reader read 51200 bytes of data.
    716348 left to read.
    Sender's runtime memory: 2818048
    Sender's free memory: 701264
    File reader read 51200 bytes of data.
    665148 left to read.
    Sender's runtime memory: 2818048
    Sender's free memory: 699560
    File reader read 51200 bytes of data.
    613948 left to read.
    Sender's runtime memory: 2818048
    Sender's free memory: 697856
    File reader read 51200 bytes of data.
    562748 left to read.
    Sender's runtime memory: 2818048
    Sender's free memory: 696152
    File reader read 51200 bytes of data.
    511548 left to read.
    Sender's runtime memory: 2818048
    Sender's free memory: 694448
    File reader read 51200 bytes of data.
    460348 left to read.
    Sender's runtime memory: 2818048
    Sender's free memory: 692744
    File reader read 51200 bytes of data.
    409148 left to read.
    Sender's runtime memory: 2818048
    Sender's free memory: 691040
    File reader read 51200 bytes of data.
    357948 left to read.
    Sender's runtime memory: 2818048
    Sender's free memory: 689336
    File reader read 51200 bytes of data.
    306748 left to read.
    Sender's runtime memory: 2818048
    Sender's free memory: 687632
    File reader read 51200 bytes of data.
    255548 left to read.
    Sender's runtime memory: 2818048
    Sender's free memory: 685928
    File reader read 51200 bytes of data.
    204348 left to read.
    Sender's runtime memory: 2818048
    Sender's free memory: 684224
    File reader read 51200 bytes of data.
    153148 left to read.
    Sender's runtime memory: 2818048
    Sender's free memory: 682520
    File reader read 51200 bytes of data.
    101948 left to read.
    Sender's runtime memory: 2818048
    Sender's free memory: 680816
    File reader read 51200 bytes of data.
    50748 left to read.
    Sender's runtime memory: 2818048
    Sender's free memory: 679112
    File reader read 50748 bytes of data.
    0 left to read.
    Creating last packet of size: 50748
    Last packet size after setting it equal to byteArray: 50748
    Here's the memory stats from the receiver:
    Receiver's free memory: 639856
    Receiver's total memory: 2842624
    Receiver's free memory: 638920
    Receiver's total memory: 2842624
    Receiver's free memory: 637984
    Receiver's total memory: 2842624
    Receiver's free memory: 637048
    Receiver's total memory: 2842624
    Receiver's free memory: 636112
    Receiver's total memory: 2842624
    Receiver's free memory: 635176
    Receiver's total memory: 2842624
    Receiver's free memory: 634240
    Receiver's total memory: 2842624
    Receiver's free memory: 633304
    Receiver's total memory: 2842624
    Receiver's free memory: 632368
    Receiver's total memory: 2842624
    Receiver's free memory: 631432
    Receiver's total memory: 2842624
    Receiver's free memory: 630496
    Receiver's total memory: 2842624
    Receiver's free memory: 629560
    Receiver's total memory: 2842624
    Receiver's free memory: 628624
    Receiver's total memory: 2842624
    Receiver's free memory: 627688
    Receiver's total memory: 2842624
    Receiver's free memory: 626752
    Receiver's total memory: 2842624
    Receiver's free memory: 625816
    Receiver's total memory: 2842624
    Receiver's free memory: 624880
    Receiver's total memory: 2842624
    Receiver's free memory: 623944
    Receiver's total memory: 2842624
    Receiver's free memory: 623008
    Receiver's total memory: 2842624
    Receiver's free memory: 622072
    Receiver's total memory: 2842624
    Receiver's free memory: 621136
    Receiver's total memory: 2842624
    Receiver's free memory: 620200
    Receiver's total memory: 2842624
    Receiver's free memory: 619264
    Receiver's total memory: 2842624
    Receiver's free memory: 618328
    Receiver's total memory: 2842624
    Receiver's free memory: 617392
    Receiver's total memory: 2842624
    Receiver's free memory: 616456
    Receiver's total memory: 2842624
    Receiver's free memory: 615520
    Receiver's total memory: 2842624
    Receiver's free memory: 614584
    this is just a sample of both receiver and sender's stats. Everything appears to be fine! Hope this message post isn't too long.
    Thanks!

  • Send data to multiple clients from a server

    My problem statement is this:
    A server is created, say X. Multiple clients are created, say A, B & C. If X sends a message to A it should reach only A and should not go to B or C. Similarly if X sends message to B it should not reach A or C. I made a one to one communication with the following code:
    //Server
    import java.io.*;
    import java.net.*;
    class X
    public static void main(String args[])throws Exception
    ServerSocket ss=new ServerSocket(4321);
    try
    Socket s=ss.accept();
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    DataOutputStream out = new DataOutputStream(s.getOutputStream());
    String str=in.readLine();
    out.writeBytes(str+"\n");
    s.close();
    ss.close();
    catch (IOException e){}
    //Client A
    import java.io.*;
    import java.net.*;
    class A
    public static void main(String args[])throws Exception
    try
    Socket s=new Socket("localhost",4321);
    BufferedReader in=new BufferedReader(new InputStreamReader(s.getInputStream()));
    System.out.println(in.readLine());
    s.close();
    catch(Exception e){}
    }But i dont know how to keep track of each client. Because all the clients sockets are created at the same port, ie. 4321. I think thread will help. But even then i dont know how to identify each client. Somebody please help. Thanks in advance.
    Edited by: sowndar on Dec 5, 2009 1:21 AM

    YoungWinston wrote:
    sowndar wrote:
    Ok. I think i have to attach an unique ID to each client message. So that, with the help of that ID, the server can identify each client. Have i caught ur point?If you don't mind using a port per client, you could do something like a receptionist taking incoming calls (on 4321 only).
    - Hi I'm Client xyz.
    - Hi Client xyz, please call me back on port abcd and I'll put you straight through to our server.
    Since 4321 is an "open line" you might have to have some sort of ID so that Clients know which return messages are meant for them, but messages on the other ports would all be direct Client to Server. Also, the Server is then is charge of port allocation and communication on the "open" port is kept to a minimum.4321 is the socket that the server is listening to. It's not what the actual communication will be carried out over. Run this, then telnet to port 12345 a few times
    public class TestServerSocket {
      public static void main(String[] args) throws Exception {
              ServerSocket server = new ServerSocket(12345);
              while (true) {
                   Socket socket = server.accept();
                   System.err.println(socket.getPort());
    }Notice how each inbound connection is allocated a unique outbound socket.

  • Reading text from server socket stream

    I have a basic cd input program i've been trying to figure out the following problem for a while now, the user enters the artist and title etc and then a DOM (XML) file is created in memory this is then sent to the server. The server then echos back the results which is later printed on a html page by reading the replys from the server line by line.
    The server must be run it listens for clients connecting the clients connect and send DOM documents through the following jsp code.
    <%@page import="java.io.*"%>
    <%@page import="java.net.*"%>
    <%@page import="javax.xml.parsers.*"%>
    <%@page import="org.w3c.dom.*"%>
    <%@page import="org.apache.xml.serialize.*"%>
    <%!
       public static final String serverHost = "cdserver";
       public static final int serverPort = 10151;
    %>
    <hr />
    <pre>
    <%
            Socket mySocket = null;          // socket object
            PrintWriter sockOut = null;      // to send data to the socket
            BufferedReader sockIn = null;    // to receive data from the socket
            try {
                //  #1 add line that creates a client socket
                mySocket = new Socket(serverHost, serverPort);
                // #2 add lines that create input and output streams
                //            attached to the socket you just created
                 sockOut = new PrintWriter(mySocket.getOutputStream(), true);
                 sockIn = new BufferedReader(new InputStreamReader(mySocket.getInputStream()));
            } catch (UnknownHostException e) {
                throw e; // This time the JSP can handle the exception, not us
            } catch (IOException e) {
                throw e; // This time the JSP can handle the exception, not us
    String cdTitle, cdArtist, track1Title, track1Time, track1Rating;
    // Retrieve the HTML form field values
    cdTitle = request.getParameter("cdtitle");
    cdArtist = request.getParameter("cdartist");
    track1Title = request.getParameter("track1title");
    track1Time = request.getParameter("track1time");
    track1Rating = request.getParameter("track1rating");
    // Create a new DOM factory, and from that a new DOM builder object
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    // Note that we are creating a new (empty) document
    Document document = builder.newDocument();
    // The root element of our document wil be <cd>
    // It gets stored as the child node of the whole document (it is the root)
    Element rootElement = document.createElement("cd");
    document.appendChild(rootElement);
    // Create an element for the CD title called <title>
    Element cdTitleElement = document.createElement("title");
    // Add a text code under the <title> element with the value that
    // the user entered into the title field of the web form (cdTitle)
    cdTitleElement.appendChild(document.createTextNode(cdTitle));
    // Place the <title> element underneath the <cd> element in the tree
    rootElement.appendChild(cdTitleElement);
    // Create an <artist> element with the form data, place underneath <cd>
    Element cdArtistElement = document.createElement("artist");
    cdArtistElement.appendChild(document.createTextNode(cdArtist));
    rootElement.appendChild(cdArtistElement);
    // Create a <tracklist> element and place it underneath <cd> in the tree
    // Note that it has no text node associated with it (it not a leaf node)
    Element trackListElement = document.createElement("tracklist");
    rootElement.appendChild(trackListElement);
    // In this example we only have one track, so it is not necessary to
    // use a loop (in fact it is quite silly)
    // But the code below is included to demonstrate how you could loop
    // through and add a set of different tracks one by one if you
    // needed to (although you would need to have the track data already
    // stored in an array or a java.util.Vector or similar
    int numTracks = 1;
    for (int i=0; i<numTracks; i++) {
      String trackNum = Integer.toString(i+1);
      Element trackElement = document.createElement("track");
      trackElement.setAttribute("id", trackNum);
      trackListElement.appendChild(trackElement);
      // Track title element called <title>, placed underneath <track>
      Element trackTitleElement = document.createElement("title");
      trackTitleElement.appendChild(document.createTextNode(track1Title));
      trackElement.appendChild(trackTitleElement);
      // Track time element called <time>, placed underneath <track>
      Element trackTimeElement = document.createElement("time");
      trackTimeElement.appendChild(document.createTextNode(track1Time));
      trackElement.appendChild(trackTimeElement);
      // Track rating element called <rating>, placed underneath <track>
      Element trackRatingElement = document.createElement("rating");
      trackRatingElement.appendChild(document.createTextNode(track1Rating));
      trackElement.appendChild(trackRatingElement);
    OutputFormat format = new OutputFormat();
    format.setIndenting(true);
    // Create a new XMLSerializer that will be used to write out the XML
    // This time we will serialize it to the socket
    // #3 change this line so that it serializes to the socket,
    // not to the "out" object
    XMLSerializer serializer = new XMLSerializer(writer, format);
    serializer.serialize(document);
            // Print out a message to indicate the end of the data, and
            // flush the stream so all the data gets sent now
            sockOut.println("<!--QUIT-->");
            sockOut.flush();
            BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
            String fromServer;
            String fromUser;
             #4 add a while loop that reads text from the
            server socket input stream, line by line, and prints
            it out to the web page, using out.println(...);
            Note that because the reply from the server will contain
            XML, you will need to call upon the toHTMLString() method
            defined below to escape the < and > symbols so that they
            will display correctly in the web browser.
            Also note that as you receive the reply back from the
            server, you should look out for the special <!--QUIT-->
            string that will indicate when there is no more data
            to receive.
            while ((fromServer = sockIn.readLine()) != null) {
            out.println(sockIn.readLine());
                // If the reply from the server said "QUIT", exit from the
                // while loop by using a break statement.
                if (fromServer.equals("QUIT")) {
                    out.println("Connection closed - good bye ...");
                // Print the text from the server out to the user's screen
                out.println("Reply from Server: " + fromServer);
                // Now read a line of text from the keyboard (typed by user)
                fromUser = stdIn.readLine();
                // If it wasn't null, print it out to the screen, and also
                // print a copy of it out to the socket
                if (fromUser != null) {
                    out.println("Client: " + fromUser);
                    sockOut.println(fromUser);
            // Close all the streams we have open, and then close the socket
            sockOut.close();
            sockIn.close();
            mySocket.close();
    %>
    I'm suppose to modify the commented sections labled with #.
    #1,2 are correct but i have doubts on the 3rd and 4th modification.
    for #3 i changed so i serializes to the socket not to the "out" object:
    from
    XMLSerializer serializer = new XMLSerializer(out, format);
    to
    XMLSerializer serializer = new XMLSerializer(writer, format);
    with "out" it prints out some of the results entered but it just hangs i'm thinking it might be the while loop that i added in #4. If i changed it to serialize the socket XMLSerializer serializer = new XMLSerializer(writer, format); it doesn't print out nothing at all; just a blank screen where it hangs.
    I can post the rest of the code (server thats in java and cdinput.html) but since i want to keep my post short and if required i'll post it later on i also omitted some of the code where it creates the DOM textnodes etc to keep my post short.

    On your previous thread, why did you say the server was using http POST and application/xml content type when it quite obviously isn't, but a direct socket communication that abuses XML comments for message end delimiters?
    The comments imply you need to wait for "<!--QUIT-->" on a line by itself, but your loop is waiting for "QUIT".
    Pete

  • WebUtil file transfer in multiple user implementation

    Hi
    Installed WebUtil and able to integrate forms/reports in Web enviroenment 10gAs.
    Around 30 to 40 people will use this application, Now to do client side integration (To Save generated output to Cleint m/c) we are geerating file on AppServer and transferring using Webutil file transfer but my question if multiple users running same report from form and generates two different date ranges to generate to same file on Appserver, How Can I use WebUtil file tranfer for two people running same report. Is that going to be problem in concurrent user environment.
    Setup 10gAs, User A select report A and run with two different data ranges and file saved on Appserver as test.pdf and now user b want to run same report with time range little bit different time range and file has to be saved to same test.pdf on ApopServer, Now how oracle going to handle this ???????.
    Pl answer this is very important as we are running this reports in Web implementation with more than 30 users.
    Many thanks in advance.
    Murthy

    Surely the real issue is that you are always generating to the same filename? Incorporate an identifier into the filename. e.g. the username
    Regards,
    Robin Zimmermann

  • Multiple client chat server

    Thanks to the help I got from the good people of this forum today I modified the chat server program which I am making and now it is working a bit better. Right now it can accept several (up to 8) clients and store their open sockets in a SocketCollection list which can later be accessed so that messages get sent to all of them. Problem is that when I send a message, it is displayed instantaneously on the client that sent that message (my machine), but is displayed only after the other clients press enter on the other clients' machines (for testing purposes it was the same machine, different port opened for communication with server which is also on the same machine). To clarify that - all clients and server are the same machine (that shouldn't be a problem, right?). Code for printing incoming data for client program is below:
    while ((fromServer = in.readLine()) != null) {
                if (fromServer!=null){
                       System.out.println(fromServer);
                       System.out.println("print on client screen msg received from server");
                fromUser = stdIn.readLine();
                if (fromUser != null) {
              System.out.println("Client: " + fromUser);
              out.println(fromUser);
    }Code to deliver the message to all clients from the server application is below as well:
    while ((inputLine = in.readLine()) != null) {
                     PrintWriter multiOut;
                   for (int x=0; x<8; x++){
                         System.out.println("INSIDE MULTI-TELL FOR LOOP");
                         if (socketCollection[x]!=null){
                               Socket c=socketCollection[x];
                               try{
                                   System.out.println("tried to send to all\nSocket c = " + c);
                                   out=new PrintWriter(c.getOutputStream(), true);
                                       out.println(c.getInetAddress() + inputLine);
                                catch(IOException ioe){}
    }In the server's DOS window I can clearly see that it enters to display the message to multiple clients and it should send it. The sockets are all different and they point to different ports on different clients' machines. Maybe the problem is just in the client program's code. If you could help me out, it will be greatly appreciated. Thank you very much.

    The sockets get created one by one when each client connects. Afterwards when the thread is made, that socket gets copied into the SocketCollection array which can afterwards be accessed in order for the server to distribute the message to all its connected clients.
    The for loop in the second code example where it takes SocketCollection[x] and gets its outputStream and all that is where it prints the message and sends it to each client (sends it but it is not displayed on the client side until the client sends a message to the server again). My question is how to make it so the client does not have to send a message in order to see the server message (message to all clients) that was sent before.

  • Multiple client single server problem(it hangs halfway)

    TestThread Class
    import java.io.*;
    import java.net.*;
    import java.awt.*;
    import javax.swing.*;
    import java.util.*;
    import java.util.Timer;// for timer
    import java.util.TimerTask;//for timer
    public class TestThread {
      public static void main(String[] args) {
        DataInputStream inputFromClient1;
        DataOutputStream outputToClient1;
        DataInputStream inputFromClient2;
        DataOutputStream outputToClient2;
        ServerSocket serverSocket = null;
        System.out.println("MastermindServer started at " + new Date() + "\n");
        try {
          serverSocket = new ServerSocket(8000);
        } catch(IOException ex) {
          System.err.println(ex);
        try {
          Socket socket = serverSocket.accept();
          System.out.println("sc1 connected \n\n\n\n");
          inputFromClient1 = new DataInputStream(socket.getInputStream());
          outputToClient1 = new DataOutputStream(socket.getOutputStream());
          String startMessage = "Two players now,You can start multiGame!";
          outputToClient1.writeUTF(startMessage);
          outputToClient1.writeUTF("hehehe");
          outputToClient1.writeUTF("hahaha");
          Socket socket1 = serverSocket.accept();
          System.out.println("sc 2 connected \n\n\n\n");
          inputFromClient2 = new DataInputStream(socket1.getInputStream());
          outputToClient2 = new DataOutputStream(socket1.getOutputStream());
          outputToClient2.writeUTF(startMessage);
          outputToClient2.writeUTF("hehehe");
          outputToClient2.writeUTF("hahaha");
    //problem starts here when both are not received
          System.out.println("Problem starts here");
          int y = new DataInputStream(socket.getInputStream()).readInt();
          System.out.println("message from client 1 : "+ y);
          int x = new DataInputStream(socket1.getInputStream()).readInt();
          System.out.println("message from client 2 : "+ x);
          outputToClient1.writeUTF("1  hehehe");
          outputToClient1.writeUTF("1  hahaha");
          outputToClient2.writeUTF("1  hehehe");
          outputToClient2.writeUTF("1  hahaha");
        } catch(IOException ex) {
          System.err.println(ex);
    }testSocket class
    import java.io.*;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import javax.swing.border.Border;//for borders
    import javax.swing.border.LineBorder;//for border lines
    import java.awt.event.ActionEvent;//for action event
    import java.awt.event.ActionListener;//for action listener
    import javax.swing.*;
    import java.util.*;
    import java.util.Timer;// for timer
    import java.util.TimerTask;//for timer
    public class testSocket {
      public static void main(String[] args) {
        new testSocket();
      public testSocket() {
           DataOutputStream outputToServer;
        DataInputStream inputFromServer;
        try {
          // Create a socket to connect to the server
          Socket socket = new Socket("localhost", 8000);
          inputFromServer = new DataInputStream(socket.getInputStream());
          outputToServer = new DataOutputStream(socket.getOutputStream());
          String message = inputFromServer.readUTF();
          System.out.println(message);//start mess
          message = inputFromServer.readUTF();
          System.out.println(message);//hehehe
          message = inputFromServer.readUTF();
          System.out.println(message);//hahaha
          message = inputFromServer.readUTF();
          new DataOutputStream(socket.getOutputStream()).writeInt(99);     
          System.out.println(message);
          message = inputFromServer.readUTF();
          System.out.println(message);
        } catch (IOException ex) {
          System.err.println(ex);
        System.out.println("connected liao");
    }Problem description:-
    I simplified this problem from my long code into 2 test files with the problem only.
    TestThread.java is the server
    testSocket.java is the client
    Running TestThread.java first then run testSocket twice without closing any would only show that it executes till line 46 and refuses to run further
    It would execute the TestThread till line 38 and not go further.
    Any help with this problem? Say I delete line 38 of testSocket and line 49-52 of TestThread, it would work fine but wouldn't work with input from different clients which would result in the program to hang there. I need to have input and output from different clients to the server at different time and interchangeable from one client to the other. In my program, the clients does different jobs so use of threads is out of the question.

    I found your mistake.
    Your clients are trying to receive a message that server has not sent.
    String message = inputFromServer.readUTF(); //read start message
    System.out.println(message);//start mess
    message = inputFromServer.readUTF(); //read hehehe message
    System.out.println(message);//hehehe
    message = inputFromServer.readUTF(); //read hahaha message
    System.out.println(message);//hahaha
    message = inputFromServer.readUTF(); //<<----- what message? hangs waiting a server message
    new DataOutputStream(socket.getOutputStream()).writeInt(99);      //this is not executed
    ...And your server hangs wait your clients int.
    Anyway, you should not recreate the DataOuputStream! use the objects you've already create.
    Lines 49 to 52 on server should be:
    int y = inputFromClient1.readInt();
    System.out.println("message from client 1 : "+ y);
    int x = inputFromClient2.readInt();
    System.out.println("message from client 2 : "+ x);It also applies to your client, see line 40.
    Regards,
    Henrique Abreu

  • SWF requested multiple times from server

    Hi,
    We have implemented an SWF in our homepage, using normal object tags. The SWF source is called from our database.
    Loading works fine, and the SWF plays OK on the page. However, using firebug or httpwatch, we can see that the same SWF is requested multiple times from the server. We only have 1 instance of the SWF on our page. At the moment I can see 6 requests to the full SWF file (about 360kb) and another 8 requests to the same file, but with a lower filesize (about 98kb).
    How is this possible? We tried using different browsers but they are giving the same results. Google doesn't answer my question, so maybe one of you can help me out here?
    Thanks in advance!

    what's your url?

  • Multiple-client, same server, different configurations

    Hi experts,
    Recently we have got a project of IS-U Electricity where it has been planned that the same server we used for the last project will be used for this upcoming project where the configurations are diffrent from each other but both of them will run together in same development, quality and production servers.
    My question is whether we would be able to configure sap as per the requirements for the upcoming project to a particular client whereas the rest of the clients will use old configurations for the existing project in the same server. Will there be any cross-client configuration conflicts?
    - Arghya

    Arghya:
    The answer to this question is unrelated the industry solution.  Multiple client scenarios are used in many solutions.  Some configuration is client dependent and so would be different in each client; other configuration is client independent and would be used in all clients.  That would be part of the analysis to determine if multiple clients or multiple systems is the correct approach.
    regards,
    bill.

  • How to get the files related to a module from server

    Hi,
    I am facing a problem. i have to extends controller but it has lot of imports from the same module but different folders. and all the files are in .class files. Can you tell me a process where i can download onto my local system from the server all the files from server and they are converted back to java files. Can i also get the xml files onto my local system.
    Please help me on this. are there any tools which can do this? plz share links.
    Thanks in advance.
    Regards,
    Prakash

    Prakash
    Its better through any tools (such as(WINFTP or WINSCP) you copy all the package structure into your local machine.For decompling all files in one go you can make use of JAD that is easily downloadable over net.
    http://www.varaneckas.com/jad
    Hope it helps!!!
    Thanks
    AJ

  • Unable to save .msg files even file screening has been uninstalled from server

    We have removed FSRM role from server by removing the file screening policy. Event though .msg or specified files not able to save on the drive.
    OS : Windows Server 2012 R2
    if we restart the server then issue gets resolve for 15 or 20 days. After that again we are not able to save such file on Drive.
     We have done the troubleshooting but no resolution yet.
    Please help.
    Thanks & Regards
    Kiran Barhate

    Hi,
    Did you create a file screening policy on the drive to prevent you from saving .msg or specified files? Can you save these files on other drives? 
    If the issue only occurred on the specified drive, please check the state of the drive and repair it if necessary.
    For more detailed information, please refer to the article below:
    http://www.microsoft.com/technet/support/ee/transform.aspx?ProdName=Windows+Operating+System&ProdVer=5.2&EvtID=55&EvtSrc=ntfs&LCID=1033
    You could also refer to the Comments: to check if it can resolve the issue:
    Event ID: 55 Source: Ntfs
    http://www.eventid.net/display.asp?eventid=55&source=Ntfs&phase=1
    Best Regards,
    Mandy 
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • File transfer speed and distance from base station?

    I tested the file transfer time (outside with no obstructions) by moving a large video file between my MacBook and a computer wired to an Airport base station.   The times were the same as distance increased until the connection dropped.  Why?

    Do the calculations.
    (Although wireless qualifies more for voodoo project than science).
    500MB translates to 5.7MB/s which is near enough to 46Mbits/s
    500MB in 94sec is 42.6Mbits/s
    That is really slow for 5ghz at such close distance to the airport.
    What OS are you running? Please open the wireless diagnostics.
    About Wireless Diagnostics - Apple Support
    Run the wireless utility.
    And get the actual link speed and how well it is working.
    Then use iperf to get actual network speeds. Rather than moving a file test the link rates.
    iperf is included in Mac OS and is available via terminal.
    This post gives some clues. http://acidx.net/wordpress/2013/05/testing-a-network-connection-with-iperf/
    I think your seeing a hold up due to slow ethernet say.. 100mbit ethernet will ruin any numbers you are trying to get in tests. As well as older slow Mechanical hdd in laptops.
    But the link speed in the Utility will tell you the story.. if you link at 450Mbps which should be possible up close.. and it drops to say 200Mbps at a range of 130M you are still far faster than the rate determining step.. very likely to be a slow disk plus slow ethernet.
    Go to the performance tab.. and keep it running as you move the computer from next to the Airport to the 130M point. You should see a pretty large drop in connect speed.. but you also need to keep this running as you transfer files.. since it tends to vary greatly during a file transfer.
    For science experiments.. this is already a pretty good one.. you are trying to determine the rate determining step in a network system and why wireless is not causing the problem you expected. The use of actual diagnostic tools is great.. almost like science.
    The big spike in this graph is me changing from 2.4ghz to 5ghz.

  • Connect one JAVA ADS instance to multiple clients from the same ABAP system

    Hi,
    Does anyone know whether it is possible to connect multplie clients from the same ABAP system to a JAVA instance running ADS?
    If so how do you setup the java destinations in Visual Admin and SM59 RFC connections?
    Any help is appreciated,
    Sander

    Dear Sander,
    this is always the case if you arrange the ADS connection.
    You have to set up the RFC connection 'ADS' in ABAP side and this connection/destination is client independent. So you can use this from all clients of your abap system.
    On Java side you have to arrange the already mentioned FP_ICF_DATA_<SID> destination. On the ABAP system and client (you specify in this destination) you have to maintain the user ADS_AGENT and your templates should also exist on this client. If there is no client defined, the default client will be used.
    Regards
    Istvan

Maybe you are looking for

  • Has anyone had issues with putting a 1TB hard drive into an early 2008 20 inch iMac?

    I have been trying to upgrade my 250GB hard to a 1TB Western Digital Blue hard drive.  So far I have tried the following... * CCC clone * Super Duper clone * Disk Utility clone * Fresh install of Mavericks and Migration Assistant Each time I do these

  • BI 7.0 Web Report and Enterprise Portal

    Hi, We have recently performed technical upgrade to BI 7.0 Now we would like to migrate web reports to NW2004s functionality. Is it necessary to configure inbuilt BI Portal before we can use web reports? Best Regards, UR

  • How run stored procedure in Crystal report?

    I have table from query in report, but first I need to run stored procedure in report. How I need to do it?

  • Loading CD's into the library

    When I load a cd into the library it sometimes loads the music as individual songs and not the cd as a whole.  Is there a way to load the cd so all the songs are listed under the cd not as individuals?  Thank you for any suggestions.

  • PO's Smartform Problem

    Hi Friends, I want to select the data for ZTERM in Terms and Conditions... ZTERM is in EKKO.. while fetching the data I am getting only the ZTERM key.. But I want all the texts that has entered in OBB8 Tcode... I have tried and searched all the ways.