Java networking(Threads) question: We must create a chat program for this assign
ID: 3588263 • Letter: J
Question
Java networking(Threads) question:
We must create a chat program for this assignment, I have done 90% of it but do not understand Threading. I have four seperate files: Client.java, Server.java, GUI.java, and MSGThread.java. Program runs, client and server gets connected and chat box shows up. I only need the threading section in GUI.java and MSGThread.java. Please help?
ps. I have made comments through out the files of the things that I thought should go in there. I really appriciate your help!
Client:
http://textuploader.com/d4r3q
•
Server:
http://textuploader.com/d4r3m
•
GUI:
http://textuploader.com/d4r3x
•
Thread:
http://textuploader.com/d4r3g
Explanation / Answer
import java.lang.*; import java.io.*; import java.net.*; class Server { public static void main(String args[]) { String data = "Toobie ornaught toobie"; try { ServerSocket srvr = new ServerSocket(1234); Socket skt = srvr.accept(); System.out.print("Server has connected! "); PrintWriter out = new PrintWriter(skt.getOutputStream(), true); System.out.print("Sending string: '" + data + "' "); out.print(data); out.close(); skt.close(); srvr.close(); } catch(Exception e) { System.out.print("Whoops! It didn't work! "); } } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.