专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Java Web开发

socket通讯联调时,收不到返回信息,求帮忙看看!

发布时间:2010-05-31 07:02:00 文章来源:www.iduyao.cn 采编人员:星星草
socket通讯联调时,收不到返回信息,求各位高手帮忙看看!!!!
我用ComMax模拟客户端发起请求,业务处理流程正常,但是没有返回报文:
TX:111111201109141406231111111111111111111115000287452 5000 (09:44:12:077)
和其他模块联调时业务处理流程正常,可是那边客户端接收不到我回写的SOCKET报文,报连接超时错误,请高手帮忙看看:
public class SocketServer {
public SocketServer(){
  Socket incoming;
  ServerSocket so;
  try{
  so= new ServerSocket(9731);
  System.out.println("等待客户端连接");
   
  while(true){
  try{
  incoming = so.accept( );
  System.out.println("已连接客户端");
  GetInfo gi=new GetInfo(incoming);
  } catch (IOException e){
  so.close();
  e.printStackTrace();
  }
  }
  }catch (IOException e){
  e.printStackTrace();
  }
  }

  public static void main(String[] args){ 
  PropertyConfigurator.configure("E:\\Myeclipse\\workspace\\oufeitest\\src\\oufei\\test\\log4j.properties");
  new SocketServer();
  }
  private static class GetInfo implements Runnable{ //�߳���
  private Socket incoming;
  private String s=null;
  private BufferedReader b;
  private BufferedWriter c;
  Thread t;

  public GetInfo(Socket incoming){
  try{
  this.incoming=incoming;
  b=new BufferedReader(new InputStreamReader(incoming.getInputStream()));
// c=new BufferedWriter(new OutputStreamWriter(incoming.getOutputStream())); 
  t=new Thread(this);
  t.start();
  }catch(IOException e){
  e.printStackTrace();
  }  
  }
   
  public void run(){
  try{
  Logger logger=Logger.getLogger(SocketServer.class);
  String lines;
  String line="";
  while ((lines = b.readLine()) != null){
  line+=lines;
  }
  System.out.println("line----"+line);
  System.out.println(line.length());
  if(line.length()%63!=0){
  logger.info("交换平台发送的报文长度不正确!");
  c.write("");
 
  } else {
  List<String> list1 = new ArrayList<String>();
  for(int i=0;i<line.length();i+=63){
  list1.add(line.substring(i,i+63));
  }
  Iterator list=list1.iterator();
  while(list.hasNext()){
  String co="";
  co=(String) list.next();
  logger.info("后台socket发送给我的内容:"+co);
  String post_url="http://esales1.ofcard.com:8088/onlineorder.do";
  String content=ConcatPackage.getPackage(co);
  //用post方式发送http请求
  String xmlcontent="";
  try {
  xmlcontent=Sender.readContentFromPost(post_url, content);
  } catch (IOException e) {
  // TODO Auto-generated catch block
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: