【问题标题】:Android Drawable, receiving image from a socketAndroid Drawable,从套接字接收图像
【发布时间】:2012-06-08 17:00:38
【问题描述】:

我通过 android 应用程序中的套接字接收图像,我进行了调试,当我将图像保存在 Drawable d 中时,程序等待发生某些事情。 我认为它必须与 clientSocket.getInputStream(); 有关系。或与插座。 我有一个 C++ 中的多线程服务器,当我停止服务器时,android 应用程序继续,我可以看到我之前发送的图像。但是,我认为这不是服务器问题,因为服务器中的套接字发送数据并显示消息 printf("Bytes enviados %d\n", bytesEnviados);这是在服务器代码的末尾。

这里有代码:

public Drawable mandaMensajeVideo(String mensaje, String ip, int puerto ) throws IOException{


    Socket clientSocket = new Socket(ip, puerto);
    DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
    outToServer.writeBytes(mensaje);
    outToServer.flush();


    InputStream inputStream = clientSocket.getInputStream();


    Drawable d = Drawable.createFromStream(inputStream, null);


    clientSocket.close();

    outToServer.close();

    return d;
}

谢谢!

【问题讨论】:

  • 你是关闭服务器端的连接,还是以其他方式表示传输结束?
  • 我免费(ssock);在服务器端
  • 但我不做 ssock.Close();
  • 但是我发送另一种信息,如字符串,我在客户端接收它
  • 听起来好像永远不会到达inputStream 的末尾,因为您从未正确关闭通信。

标签: android sockets tcp drawable inputstream


【解决方案1】:

听起来好像永远不会到达inputStream 的末尾,因为您从未正确关闭通信。

【讨论】:

    猜你喜欢
    • 2015-03-22
    • 2014-03-25
    • 2019-01-26
    • 1970-01-01
    • 2023-03-05
    • 2014-08-16
    • 2017-02-25
    • 1970-01-01
    • 2021-12-19
    相关资源
    最近更新 更多