Results 1 to 2 of 2
  1. #1
    nigamsir is offline Member
    Join Date
    Mar 2010
    Posts
    11
    Rep Power
    0

    Default Sending Text File --- Server-To-Client

    I want to send file which is created at the server to the client and then read the file contents

    Server
    ======
    ....
    providerSocket = new ServerSocket(2004, 3);
    System.out.println("Waiting for connection");
    connection = providerSocket.accept();
    ...
    KeyPair keyPair = KeyPairGenerator
    .getInstance("RSA")
    .generateKeyPair();
    ServerPublicKey = keyPair.getPublic();
    ServerPrivateKey = keyPair.getPrivate();

    FileOutputStream fosSvrKU = new FileOutputStream("fosServerKU1.txt");
    DataOutputStream dosSvrKU = new DataOutputStream(fosSvrKU);
    dosSvrKU.writeUTF(ServerPublicKey.toString());
    dosSvrKU.flush();
    dosSvrKU.close();

    Client
    ======
    ....
    clientSocket = new Socket("localhost",2004);
    ????

  2. #2
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    364
    Rep Power
    5

    Default

    You have nice network tutorial on this forum on this topic

    http://www.java-forums.org/java-tuto...amming-ii.html

    Be sure you basic client/server socket comunication work
    with simple message exchange
    then move on to sending file.

    Why are you using KeyPairs for this.
    Are security issues important?
    If not skip them for start.
    Create unsecure solution first then move to security - it can be much complex than all this.

    regards

Similar Threads

  1. Replies: 8
    Last Post: 02-18-2010, 12:54 PM
  2. Replies: 3
    Last Post: 12-10-2009, 03:49 PM
  3. Replies: 3
    Last Post: 07-29-2009, 04:52 AM
  4. Replies: 1
    Last Post: 02-10-2009, 09:16 AM
  5. sending jar files from client to server?
    By gobinathm in forum New To Java
    Replies: 2
    Last Post: 11-13-2007, 05:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •