Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer the coding as below highlight. package mutu.pos.server; import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; /** * */ public class POSServer { private static final

Please answer the coding as below highlight.

package mutu.pos.server;

import java.io.IOException; import java.net.ServerSocket; import java.net.Socket;

/** * */ public class POSServer {

private static final String STOCKSFILE = "stocks.csv"; private static final String TRANSFILE = "trans.csv"; /** * @param args the command line arguments */ public static void main(String args[]){ try{ String desktopPath = System.getProperty("user.home") + "/Desktop/"; SharedObject _obj = new SharedObject(desktopPath + STOCKSFILE, desktopPath + TRANSFILE); //1. create a server Socket ServerSocket ssk = new ServerSocket(12345); System.out.println("Server started"); while(true){ //2. get the client socket Socket _skt = ssk.accept(); //3. create the client handler object and pass the _obj to it ClientHandler _h = new ClientHandler(_obj, _skt); //4. start the client handler new Thread(_h).start(); System.out.println("A connection received"); } } catch (IOException ioe){ System.out.println(ioe.getMessage()); }//end of try-catch }//end of main() }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions