Results 1 to 10 of 10
  1. #1
    pavan kalyan is offline Member
    Join Date
    Feb 2015
    Posts
    4
    Rep Power
    0

    Default Please help me out with the code

    Byte Counting Server

    Write a server for a client. The client sends text messages to the server line by line.

    For each line entered by the user on the client side, the server receives the line of message,

    calculates the number of bytes received so far, and sends

    them back to the client. The client terminates the communication by

    sending a single line with FIN. Write your server and client applications using TCP.

    Your server should be able to serve multiple clients at the same time (multithreading server).

    On the client side, the command line interface of the program looks like:

    Java client hostname 6066

    Hello

    5 bytes received by server

    Good Morning

    17 bytes received by server

    (continue ....)

    FIN

    Total 700 bytes received by server

    Please help me out with the code ?

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Please help me out with the code

    You need to post your current attempt and explain what problems you are having. We won't just write your code for you.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    pavan kalyan is offline Member
    Join Date
    Feb 2015
    Posts
    4
    Rep Power
    0

    Default Re: Please help me out with the code

    Quote Originally Posted by jim829 View Post
    You need to post your current attempt and explain what problems you are having. We won't just write your code for you.

    Regards,
    Jim

    Hi iam new to java platform and finding it difficult to code ...so i need your help so that i can learn a bit ..

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Please help me out with the code

    Quote Originally Posted by pavan kalyan View Post
    Hi iam new to java platform and finding it difficult to code ...so i need your help so that i can learn a bit ..
    If you are new to Java then why are you writing something relatively advanced? That makes little sense.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  5. #5
    pavan kalyan is offline Member
    Join Date
    Feb 2015
    Posts
    4
    Rep Power
    0

    Default Re: Please help me out with the code

    Please help me Jim

  6. #6
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Please help me out with the code

    Quote Originally Posted by pavan kalyan View Post
    Please help me Jim
    Sorry. If I were to write your code for you I would be chastised by the forum community (and rightly so). I recommend you get a book, check out a video, or look at the tutorials linked in my signature.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  7. #7
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Please help me out with the code

    First, please place your code between code tags .

    I do not know how you plan on running this but I would have the server running in a separate thread, waiting for input from the client.

    Regards,
    Jim
    Last edited by jim829; 02-02-2015 at 12:33 AM.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  8. #8
    pavan kalyan is offline Member
    Join Date
    Feb 2015
    Posts
    4
    Rep Power
    0

    Default Re: Please help me out with the code

    Quote Originally Posted by jim829 View Post
    First, please place your code between code tags .

    I do not know how you plan on running this but I would have the server running in a separate thread, waiting for input from the client.

    Regards,
    Jim

    Hey Jim ,

    When i send a message say Hi from the server , the client shoud read no.of bytes of that string ..

    i am unabale to implement the logic over there , if you are interested please do help me or else just leave it ..

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Please help me out with the code

    Quote Originally Posted by pavan kalyan View Post
    I am done with TCP Client Server socket programming and i have suceeded in execution but iam unable to handle the above case ..
    Here is the code which i have executed on client and server side ..
    Did you forget to include the copyright notice, or was that intentional?
    Java Code:
    /*
     * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     *   - Redistributions of source code must retain the above copyright
     *     notice, this list of conditions and the following disclaimer.
     *
     *   - Redistributions in binary form must reproduce the above copyright
     *     notice, this list of conditions and the following disclaimer in the
     *     documentation and/or other materials provided with the distribution.
     *
     *   - Neither the name of Oracle or the names of its
     *     contributors may be used to endorse or promote products derived
     *     from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
     * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
     * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
     * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  10. #10
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,989
    Rep Power
    8

    Default Re: Please help me out with the code

    Quote Originally Posted by DarrylBurke View Post
    Did you forget to include the copyright notice, or was that intentional?
    db
    LOL! Well spotted :)

    http://docs.oracle.com/javase/tutori...ockClient.java
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

Similar Threads

  1. Replies: 16
    Last Post: 01-31-2012, 08:36 PM
  2. Replies: 3
    Last Post: 08-10-2011, 09:17 AM
  3. Replies: 0
    Last Post: 08-07-2011, 08:32 PM
  4. Replies: 0
    Last Post: 02-21-2011, 11:50 AM
  5. Replies: 1
    Last Post: 04-26-2007, 03:52 PM

Posting Permissions

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