Sie sind auf Seite 1von 14

1 st phase of Semester

Programming Project
By Rina Patel

Detail of Final Project


The final project will require four
programs running separately over a
network, emulating four routers with
predefined connections and route
costs, that communicate with each
other to update Distance Vector
Routing Tables at each router, while
displaying changes and resulting
tables for Router 0.

Options for implementation


You may choose c,c++ or java

Functionality of 1 stage :
st

Create a client program and a server


program, communicating over a
network, and passing the
information.
Client displays information received
from server.

Resouces of Technical
support -1
You need to install VPN and establish a
VPN connection from off-campus.
Mac OS X's built-in command-line SSH
and sFTP work just fine with NJITs
UCS servers
For Windows use SSH Secure Shell,
both in terminal mode to run
commands and in file transfer mode
to upload files.

Resouces of Technical
support -2
Preferred Systems: afsaccess1, afsaccess2,
afsaccess3 and afsaccess4
Alternates: afsconnect1 and afsconnect2
These systems are heavily loaded and
busy.
Some pages at http://ist.njit.edu/ suggest
that you use afs1 thru afs33. All the odd
numbers are now redirected to
afsconnect1 and all the even numbers to
afsconnect2.

Using java
To compile a Java program :
javac yourFilename.java
To run it :
java yourFilename.class

Client and server :


Client end - TCPClient.java
- at the local machine
Server end - TCPServer.java
- on the njit afs account

Code for client.java


import java.io.*;
import java.net.*;
class TCPClient {
public static void main(String argv[]) throws Exception
{
String request;
String response;
BufferedReader inFromUser = new BufferedReader(new
InputStreamReader(System.in));
Socket clientSocket = new Socket("afsaccess1.njit.edu",6699);
DataOutputStream outToServer = new
DataOutputStream(clientSocket.getOutputStream());
BufferedReader inFromServer = new BufferedReader(new
InputStreamReader(clientSocket.getInputStream()));
request = inFromUser.readLine();
outToServer.writeBytes(request + '\n');
response = inFromServer.readLine();
System.out.println("FROM SERVER : " + response);
clientSocket.close();
}

Code for Server.java


import java.io.*;
import java.net.*;
class TCPServer {
public static void main(String agrv[]) throws Exception
{ String clientrequest;
String returnresponse;
ServerSocket welcomeSocket = new ServerSocket(6699);
while(true) {
Socket connectionSocket = welcomeSocket.accept();
BufferedReader inFromClient = new BufferedReader(new
InputStreamReader(connectionSocket.getInputStream()));
DataOutputStream outToClient = new
DataOutputStream(connectionSocket.getOutputStream());
clientrequest = inFromClient.readLine();
returnresponse = clientrequest + " : Response Returned" + '\n';
outToClient.writeBytes(returnresponse);
}
}
}

Varification of client file complied :

Verification of uploaded and


complied server file :

Client server comminication -1

Client server comminication - 2

Das könnte Ihnen auch gefallen