Skip to content
Snippets Groups Projects
LandasServer1.java 1.36 KiB
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package MV3500Cohort2018JanuaryMarch.homework1;

import java.io.*;
import java.net.*;

/**
 *
 * @author Rico
 */
public class LandasServer1 {

    /**
     * @param args command-line arguments
     */
    public static void main(String[] args) {
        
        try
        {
            ServerSocket ss = new ServerSocket(2317);
            
            while(true) {
                
                Socket cs = ss.accept();
                BufferedReader cbr = new BufferedReader(new InputStreamReader(cs.getInputStream()));
                String temp = cbr.readLine();
                //System.out.println("Client:" + temp);
                //JOptionPane.showMessageDialog(null,"Salam");
                PrintStream spr = new PrintStream(cs.getOutputStream());
                String temp1 = "Server: I got your message: " + temp;
                spr.println(temp1);
                //server();
                
            }
            
            
        }
        catch(Exception e) {
            System.out.println("problem with networking");
        }
        
        
        
        
        
        
        
        
    }
    
}