Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Computer Networks Programming Assign 1 For this assignment you are to implement

ID: 3527036 • Letter: C

Question

Computer Networks Programming Assign 1 For this assignment you are to implement both a TCP server and a TCP client piece of software. You may use any high level language that provides built in networking support. A great starting point will be the iserver.c and iclient.c programs on the class webpage. The server is to accept a connection from a client and receive a text message of no more than 80 characters. It will convert the message to an encoded message as detailed next. Your server will convert each character by replacing it with the next character in the ASCII sequence. For example the message:

Explanation / Answer

I have implement the simple TCP server and TCP client classes which can send the message from client to server and the message will be converted to upper case on the server side, but how can I achieve transfer files from server to client and upload files from client to server. the following codes are what I have got. TCPClient.java: import java.io.*; import java.net.*; class TCPClient { public static void main(String args[]) throws Exception { String sentence; String modifiedSentence; BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); Socket clientSocket = new Socket("127.0.0.1", 6789); DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream()); BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); sentence = inFromUser.readLine(); outToServer.writeBytes(sentence + " "); modifiedSentence = inFromServer.readLine(); System.out.println("FROM SERVER:" + modifiedSentence); clientSocket.close(); } } TCPServer.java: import java.io.*; import java.net.*; class TCPServer { public static void main(String args[]) throws Exception { int firsttime = 1; while (true) { String clientSentence; String capitalizedSentence=""; ServerSocket welcomeSocket = new ServerSocket(3248); Socket connectionSocket = welcomeSocket.accept(); BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream())); DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream()); clientSentence = inFromClient.readLine(); //System.out.println(clientSentence); if (clientSentence.equals("set")) { outToClient.writeBytes("connection is "); System.out.println("running here"); //welcomeSocket.close(); //outToClient.writeBytes(capitalizedSentence); } capitalizedSentence = clientSentence.toUpperCase() + " "; //if(!clientSentence.equals("quit")) outToClient.writeBytes(capitalizedSentence+"enter the message or command: "); System.out.println("passed"); //outToClient.writeBytes("enter the message or command: "); welcomeSocket.close(); System.out.println("connection terminated"); } } } So, the TCPServer.java will be executed first, and then execute the TCPClient.java, and I try to use the if clause in the TCPServer.java to test what is user's input,now I really want to implement how to transfer files from both side(download and upload).Thanks.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote