This preview has intentionally blurred parts. Sign up to view the full document

View Full Document

Unformatted Document Excerpt

import java.io.*; import java.net.*; 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... View Full Document

End of Preview

Sign up now to access the rest of the document