public static String postTOServer(String ip_port ,int nodexml)
{
logger.error("node Xml is "+Node.writeToString(nodexml,true));
Socket requestSocket = null;
ObjectOutputStream out = null;
ObjectInputStream in = null;
String message = null;
String ip_port_split[] = ip_port.split("@");
String ip_p = null;
Integer ip_ip = 0;
if(ip_port_split.length != 0 && nodexml != 0)
{
ip_p=ip_port_split[0];
logger.error("Ip_p is "+ip_p);
ip_ip=Integer.parseInt(ip_port_split[1]);
logger.error("Ip_ip is "+ip_ip);
try{
requestSocket = new Socket(ip_p, ip_ip);
out = new ObjectOutputStream(requestSocket.getOutputStream());
out.flush();
in = new ObjectInputStream(requestSocket.getInputStream());
logger.error("request Socket Input Stream "+requestSocket.getInputStream());
/*FileInputStream fstream = new FileInputStream(filepath);
BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
String strLine;
String xml = "";
while ((strLine = br.readLine()) != null) {
xml = xml + strLine;
}*/
sendMessage(Node.writeToString(nodexml, false),out);
in.
message = (String)in.readObject();
logger.error("The Message is "+message);
}
catch(ClassNotFoundException classNot){
logger.error("Class Not Found "+classNot);
}
catch(UnknownHostException unknownHost){
logger.error("Unknown Host Exception "+unknownHost);
}
catch(IOException ioException){
logger.error("Io Exception 1 "+ioException);
}
finally{
//4: Closing connection
try{
in.close();
out.close();
requestSocket.close();
}
catch(IOException ioException){
logger.error("Io Exception in Finally Block "+ioException);
}
}
}
else{
throw new BsfConstraintViolationException("Error Message");
}
return message;
}
public static void sendMessage(String msg,ObjectOutputStream out)
{
try{
out.writeObject("Content-Type: text/xml; charset=\"utf-8\"\r\n");
//out.writeObject(msg);
logger.error("The Message Which is getting Posted "+msg);
out.flush();
}
catch(IOException ioException){
logger.error("Io Exception in sendMessage MEthod "+ioException);
}
}
私は次の例外を取得しています:
Io 例外 1 java.net.SocketException: ソフトウェアが原因で接続が中止されました: recv が失敗しました