Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

TCP & UDP client/server - need help!

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi..can anybody help me with this??? Tq...

Assignment
The goal of this assignment is to implement a TCP client and server, and a UDP client and server (for a total of four different programs). You can use Java. Your TCP or UDP client/server will communicate over the network and exchange data.
The server will start in passive mode listening on a specified port for a transmission from a client. Separately, the client will be started and will contact the server on a given IP address and port number that must be entered via the command line. The client will pass the server a string consisting of a sequence of characters. If the string contains anything but numbers, the server will respond with "Sorry, cannot compute!" and exit. If the string contains all numbers, the individual digits will be added together and returned as a string (see below for an example). If the server sends a "Sorry" response to the client it will immediately exit. If the server receives a string of numbers, it will (1) add the digits together, (2) send the value back to the client, and (3) will not exit unless the response is a single digit. This process will be repeated until there is only one digit remaining. Note: the server will send a new packet each time Step (2) is executed, and the client will expect to receive a packet until there is only a single digit. See below for the exact output.
Examples
Starting the Server
Assume that you started a server on machine 128.111.49.44, listening to port number 32000. The syntax should look like the following:
machine1> server 32000
oIn this example, "server" should be replaced by one of the names given below in the Submission section.
oThe server should not produce any output but should end after interacting with a client.

Starting the Client
machine2> client 128.111.49.44 32000
oIn this example, "client" should be replaced by one of the names given below in the Submission section.
Client Input/Output for Non-Numeric Example
machine2> client 128.111.49.44 32000
Enter string: I don't like addition!!
From server: Sorry, cannot compute!
machine2>

Client Input/Output for Numeric Example
machine2> client 128.111.49.44 32000
Enter string: 123456789101234567891012345678910
From server: 138
From server: 12
From server: 3
machine2>
Turn In
You must turn in exactly four programs (should be included in the one file).
The program names should be:
�Server in Java using UDP (file name to turn in: server_java_udp.java)
�Client in Java using UDP (file name to turn in: client_java_udp.java)
�Server in Java using TCP (file name to turn in: server_java_tcp.java)
�Client in Java using TCP (file name to turn in: client_java_tcp.java)
To compile your Java code, use the following commands:
"javac server_java_udp.java"
"javac client_java_udp.java"
"javac server_java_tcp.java"
"javac client_java_tcp.java"
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

What do you have so far, and what are you stuck with?

The Sun Java Tutorial has an extensive chapter on client/server programming, which includes examples codes for client and server for both UDP and TCP.
 
Albert Hopkins
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well..
If you can tell me where I can find a working code, it would be fine.

The purpose for this assignment is to gather as many examples I can get from the internet. From that example, I have to do report describing every code and the functions.

Tq.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I am currently studying Bachelor in computer science can someone help with the TCP and UDP program which has post above.

Can i get the full source code for the program please?
 
Marshal
Posts: 28271
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi rivishaa kanna, welcome to the Ranch!

It's good that you searched the forums to find a question related to yours. We encourage that. But... you'll notice that the original poster has been waiting over 10 years for an answer. That's because the Ranch isn't a code-writing service. We're here to answer questions and help you along, but that's it.

So if your goal is to write those programs, and you're having trouble with that, then by all means tell us about your problems and ask some questions. But if you're just looking for code, it seems to me you should be able to find some examples on the web. Even 10 years ago there was code on the web, as you can see by one of the earlier answers in this thread. If you're having trouble working out what search terms to use in your web search, you could ask about that here as well.
 
Something about .... going for a swim. With this tiny ad ...
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic