Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.gmail.dimitrischeibe.xti.redes;
- import java.io.IOException;
- import java.net.ServerSocket;
- import java.net.Socket;
- import java.util.Scanner;
- public class ChatServer {
- ServerSocket server;
- Scanner leitor;
- public ChatServer() {
- try {
- server = new ServerSocket(4013);
- while(true) {
- Socket socket = server.accept();
- new Thread(new EscutaClient(socket)).start();
- }
- } catch (IOException ex) {
- }
- }
- private class EscutaClient implements Runnable{
- public EscutaClient(Socket socket) throws IOException {
- Scanner leitor = new Scanner(socket.getInputStream());
- }
- @Override
- public void run() {
- String texto;
- texto = leitor.nextLine();
- while(texto != null) {
- System.out.println(texto);
- }
- }
- }
- public static void main(String[] args) {
- new ChatServer();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment