server_java_tcp - import*; import*;...

Download Document
Showing pages : 1 of 4
This preview has blurred sections. Sign up to view the full version! View Full Document
import*; import*; import java.util.*; /* Code used from Kurose and Ross book (Computer Networking): type BufferedReader, ServerSocket, Socket, DataOutputStream. */ class server_java_tcp { public static void main(String[] args) throws Exception { String clientExpr; int portNum = Integer.parseInt( args[0] ); ServerSocket welcomeSocket = new ServerSocket(portNum); Stack<Float> operand = new Stack<Float>(); Stack<Character> operator = new Stack<Character>(); while (true) { // Code Used from Computer Networking book Socket connectionSocket = welcomeSocket.accept(); BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream())); DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream()); clientExpr = inFromClient.readLine(); //////////////////////////////////////////// char currChar; // keep track of current char in expression string char[] str = new char[clientExpr.length()]; // used to convert characters of digits (e.g. 2.333) into float int index = 0; // track position of char[] str
Background image of page 1
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.