server_java_tcp - import*; import*;...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
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

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

server_java_tcp - import*; import*;...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online