Client_PTB2_TCP

Client:

import java.io.*;

import java.net.*;

class PTB2_TCP_Client

{

public static void main (String arg[]) throws Exception

{

while(true)

{

Socket skcl=new Socket("Tenmay",6789);

DataInputStream input=new DataInputStream(System.in);

double a,b,c;

do

{

System.out.print("a (a <> 0): ");

a=Double.parseDouble(input.readLine().trim());

}while(a==0);

System.out.print("b: ");

b=Double.parseDouble(input.readLine().trim());

System.out.print("c: ");

c=Double.parseDouble(input.readLine().trim());

DataOutputStream toServer=new DataOutputStream(skcl.getOutputStream());

toServer.writeDouble(a);

toServer.writeDouble(b);

toServer.writeDouble(c);

DataInputStream fromServer=new DataInputStream(skcl.getInputStream());

String ketqua=fromServer.readUTF();

System.out.println(ketqua);

skcl.close();

}

}

}

Bạn đang đọc truyện trên: AzTruyen.Top

Tags: #hieu