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.

Create a FREE account now to get started. Log In

The email address you entered is not valid. The email address you provided is already in use.
Your username must be at least 5 characters. Your username must consist of only alphanumeric characters. Your username must contain at least one letter. Your username contains inappropriate language. Another user has already claimed this username.
Your password must be at least 6 characters in length.
{[ $select.selected.label ]} Please select a valid school.
By creating an account you agree to our Privacy Policy, Terms of Use, and Honor Code.
Create my FREE account Processing...
Sign Up with Facebook

We will never post anything without your permission.

Already on Course Hero? Log In