import java.io.*;
import java.util.Scanner;
import java.net.*;
public class Server1 {
static ServerSocket ss = null;
static InputStream is = null;
static Socket s = null;
static OutputStream os = null;
public static void main(String[] args){
try{
ServerSocket ss = new ServerSocket(7000);
System.out.println("Listening");
s = ss.accept();
System.out.println("Server is Connect");
is = s.getInputStream();
os = s.getOutputStream();
Scanner scan = new Scanner(is);
while(scan.hasNextLine())
{
String data = scan.nextLine();
System.out.println("User : " + data);
}
}
catch(IOException e)
{
e.printStackTrace();
}
finally{
try{
s.close();
os.close();
is.close();
ss.close();
}
catch(IOException e){
e.printStackTrace();
}
}
}
}
import java.util.Scanner;
import java.net.*;
public class Server1 {
static ServerSocket ss = null;
static InputStream is = null;
static Socket s = null;
static OutputStream os = null;
public static void main(String[] args){
try{
ServerSocket ss = new ServerSocket(7000);
System.out.println("Listening");
s = ss.accept();
System.out.println("Server is Connect");
is = s.getInputStream();
os = s.getOutputStream();
Scanner scan = new Scanner(is);
while(scan.hasNextLine())
{
String data = scan.nextLine();
System.out.println("User : " + data);
}
}
catch(IOException e)
{
e.printStackTrace();
}
finally{
try{
s.close();
os.close();
is.close();
ss.close();
}
catch(IOException e){
e.printStackTrace();
}
}
}
}
Comments
Post a Comment