如何使用Volley库通过套接字(IP地址)和端口号(例如1234)进行网络呼叫? [英] How to use volley library for network call using Socket(IP address) and port number(eg. 1234)?

查看:98
本文介绍了如何使用Volley库通过套接字(IP地址)和端口号(例如1234)进行网络呼叫?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想发送字节[]进行请求,在响应中我将得到字节[].所以请您帮我.

现在我正在将Asynctask doInBackground()用于网络调用和Socket类.

已经通过某个链接,但是找不到解决方案. 预先感谢.

解决方案

似乎Volley是一个 http 库,请参见 Kryonet 是另一个非常好的Java网络库,用于发送TCP和 网络上的UDP数据包也可以在Android上高效运行. 尽管每当我使用Kryonet时,我都写了服务器端代码和 使用此库的客户端代码. Kryonet保持联系 虽然还活着,所以如果您在更改服务器时没有任何问题 从Python到Java的辅助代码(Kryonet提供了一些示例供您使用), 那么它将很好地满足您的目的.使用此库,您无需 甚至需要对任何IP地址进行硬编码.你可以发现当地 只需一行代码即可实时访问服务器.

引自此处

I want to send byte [] to make a request and in the response i will get the byte[].So can you please help me.

Right now i am using the Asynctask doInBackground() for the network call and Socket class.

Had gone through some link but could not found the solution. Thanks in advance.

解决方案

Seems Volley is a http library, see this. It's good enough to use AsyncTask for this.

Edit

Kryonet is another very good Java network library for sending TCP and UDP packets over network efficiently which runs on Android as well. Though whenever I used Kryonet, I wrote both the server side code and client side code using this library. Kryonet keeps the connection alive though, so if you don't have any issues changing your server side code from Python to Java (Kryonet has samples which you can use), then it will serve your purpose well. Using this library, you don't even need to hardcode any IP address. You can discover the local server in real time with just one line of code.

Quoted from here

这篇关于如何使用Volley库通过套接字(IP地址)和端口号(例如1234)进行网络呼叫?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆