Socket Read Stream
protected BufferedReader cin = NULL; Socket Read Stream
Socket send Stream
protected PrintWriter cout;
/*************************************************************************** * Send information to CCB ************************ **************************************************/
public static string Sendmsgjsyh (String msg, String sydwid) throws Fesexception {
String message = "";
Get the service IP String serviceip= "";
Gets the service port int port=0;
try {
Get Service IP Serviceip = fesurlconfig.getfesconfig (). GETITCCBIP ();
serviceip= "172.16.17.24";
Get service Ports port = Fesurlconfig.getfesconfig (). Getitccbport ();
port=8000;
Socketclients sc = new socketclients (SERVICEIP, Port);
Log.error ("CCB Service (IP:" + Serviceip + "ports:" + port);
Message = Sc.sendxmlmsgtojsyhls (Msg.getbytes ());
} catch (Connectexception e) {
Log.error ("CCB Service (IP:" + Serviceip + "PORT:" + port + ") connection failed! "+ e.getmessage ());
throw new Fesexception (e);
} catch (Sockettimeoutexception e) {
Log.error ("CCB Service (IP:" + Serviceip + "PORT:" + port + ") Response timed out! "+ e.getmessage ());
throw new Fesexception (e);
} catch (Exception e) {
Log.error (E.getmessage (), E);
}
return message; }
Method 2:
Public String Sendxmlmsgtojsyhls (byte[] sendmsg) throws Exception {
Establish connection this.startconnect ();
Logger.info ("\nsend message:\n" + new String (sendmsg));
Send Message This.sendbuffer (SENDMSG);
Receive Message byte[] responsemsg = This.recievebufferyh ();
Close connection this.shutdownconnection ();
String Msgres =new string (responsemsg);
return msgres;
}
/**
* @description Send Information
* @author Fei_yfan
* @param bufferstring
* Send Message content
* @throws IOException
*/
public void Sendbuffer (byte[] bufferstring) throws IOException {
Cout.write (New String (bufferstring));
Cout.flush ();
}
Public byte[] Recievebufferyh () throws Exception {
StringBuffer sb = new StringBuffer ();
String s = "";
Reads the contents in bytes from the file, to the end of the file, the Read method returns 1
while ((S=cin.readline ()) = null) {
Sb.append (s+ "\ n");
}
Return sb.tostring (). GetBytes ();
}
TCP/IP transport