import java.net.*;
import java.io.*;
public class Client
{
Socket s;
DataInputStream is;
DataOutputStream os;
String net_Status="OK";
Client()
{
try
{
s=new Socket("X.X.X.X",port number);
^
|
replace with your server IP and port no.
net_Status="Connected";
is=new DataInputStream(s.getInputStream());
os=new DataOutputStream(s.getOutputStream());
}
catch (Exception e)
{
net_Status="Server Error :"+e.toString();
};
};
public void sendRequest(String str)
{
try
{
os.writeUTF(str);
}
catch(Exception e) {
net_Status="Server Error :"+e.toString();
};
};
public String getResponse()
{
try
{
String rp=is.readUTF();
return rp;
}
catch (Exception e)
{
net_Status="No data received";
return "None";
};
};
public void shutDown()
{
try
{
is.close();
os.close();
s.close();
}
catch (Exception e) {};
};
};