import java.io.*;
import java.net.*;
import java.util.*;
//
public class Server {
@SuppressWarnings("resource")
public static void main(String[] args) throws IOException {
String msg=null;
Scanner scan=new Scanner(System.in);
System.out.print("Port: ");
int port=scan.nextInt();
ServerSocket server=new ServerSocket(port);
System.out.println("Listening on port: " + port);
Socket socket=server.accept();
System.out.println("Connection from: " + socket.getLocalAddress().getHostAddress());
while(true){
PrintWriter out=new PrintWriter(socket.getOutputStream(),true);
msg=scan.nextLine();
out.println(msg);
out.flush();
System.out.println("Server: " + msg);
}
}
}
[Question] Java chat program
Page 1 of 12 Replies - 156 Views - Last Post: 24 November 2012 - 10:19 PM
#1
[Question] Java chat program
Posted 24 November 2012 - 02:07 PM
Hi, everyone! I`m (beginner by the way)coding some chat program in java. I know i need to use Thread in there but i don't where to insert it in. Here is my code. I would appreciate any help
/> . This is a server.class
Replies To: [Question] Java chat program
#2
Re: [Question] Java chat program
Posted 24 November 2012 - 04:17 PM
There's a chat application tutorial in the Java tutorials section that covers everything nicely.
#3
Re: [Question] Java chat program
Posted 24 November 2012 - 10:19 PM
farrell2k I am afraid your friend iSpectrum would need quite a basic but really basic tutorial
http://www.dreaminco...snippet1917.htm
then he can go on more complicated stuff like a chat room
http://www.dreaminco...r-gui-optional/
http://www.dreaminco...snippet1917.htm
then he can go on more complicated stuff like a chat room
http://www.dreaminco...r-gui-optional/
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|