需要连服务器的手机app一般用什么协议?Tcp/ip还是REST API
所有app连接服务器均使用TCP/IP协议。其余的API只是基于TCP/IP的一些封装而已,底层通信使用的都是TCP/IP协议。

java写的socket tcp连接在小米手机上,app在前台tcp连接正常,app一退到后台或锁屏,tcp过一会儿就断开了
最近我在在写一个APP,用到了socket,在自己电脑上搭建的服务器,具体过程:用eclipse写Java代码,创建一个serversocket,用来监听客户端的请求;客户端在发送数据前,首先创建一个Socket,然后直接请求服务器即可。
这是当然的,socket是阻塞的,你要开个线程跑

pc端服务器和手机客户端进行TCP/IP的socket连接
楼主应该明白这个实现方法可以利用SUN公司的Eclipse软件来模拟实行。具体安装该软件的方法图书馆里有书具体介绍。Java实用技术的书。 下面是程序代码一:public class HttpMIDlet extends MIDlet {public Display display=Display.getDisplay(this);public Form form=new Form("TEST");public HttpMIDlet() {// TODO Auto-generated constructor stubdisplay.setCurrent(form);}protected void destroyApp(boolean arg0) throws MIDletStateChangeException {// TODO Auto-generated method stub}protected void pauseApp() {// TODO Auto-generated method stub}protected void startApp() throws MIDletStateChangeException {// TODO Auto-generated method stubtry {HttpConnection hc=(HttpConnection) Connector.open("http://localhost:8080/http2009/HttpHttpServlet",Connector.READ_WRITE);hc.setRequestMethod(HttpConnection.POST);DataOutputStream dos=hc.openDataOutputStream();dos.writeUTF("合肥");dos.close();DataInputStream dis=hc.openDataInputStream();String temp=dis.readUTF();dis.close();form.append(temp);} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}代码二:public class HttpHttpServlet extends HttpServlet {public HttpHttpServlet() {// TODO Auto-generated constructor stub}@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {// TODO Auto-generated method stubsuper.doGet(req, resp);}@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {// TODO Auto-generated method stubDataInputStream dis=new DataInputStream(req.getInputStream());String temp=dis.readUTF();dis.close();DataOutputStream dos=new DataOutputStream(resp.getOutputStream());dos.writeUTF(temp+"OK");dos.close();super.doPost(req, resp); }
提供给您简单的实例,并为您附加上必要的解释。 服务器端(PC端) tomcat服务器建立一个web项目,并新建一个servletservlet代码如下import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class j2meServlet extends HttpServlet{public j2meServlet() {super();}public void destroy(){super.destroy();}public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{this.doPost(request, response);}userDao user = new userDao(); //查询数据库的实例String[] st = null;byte[] data = null;public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{String id = request.getParameter("id");//用getParameter得到手机端发送过来的字符串st = user.getUser(Integer.parseInt(id));//根据得到的ID向数据库查询System.out.println(st[0] + "<<<==>>>" + st[1]);//信息输出String message = "";for(int i=0; i :" + url);hcon.setRequestMethod( HttpConnection.POST );dos = hcon.openDataOutputStream();byte[] byteRequest = requestBody.getBytes();for( int i = 0; i < byteRequest.length; i++ ){dos.writeByte(byteRequest[i]);}dis = new DataInputStream( hcon.openInputStream() );int ch;while ( ( ch = dis.read() ) != -1 ){message = message.append( ( char ) ch );}System.out.println("=== :" + message);}catch( Exception e ){e.printStackTrace();message.append( "ERROR" );}finally{try{if ( hcon != null ) hcon.close();if ( dis != null ) dis.close();if ( dos != null ) dis.close();}catch (IOException e){e.printStackTrace();}}return message.toString(); }
哇,高科技啊。整不明白

平安银行app怎么老显示网络连接不上
建议重新下载最新版口袋银行APP尝试。 如一直显示异常,可拨打95511-2转人工反馈。
一般来讲,银行的app是绝对没有问题的,原因可能是你网络故障或者信号不好。网络故障(network failure)是指由于硬件的问题、软件的漏洞、病毒的侵入等引起网络无法提供正常服务或降低服务质量的状态。拓展:1、一般都是由架构网络的设备,包括网卡、网线、路由、交换机、调制解调器等设备引起的的网络故障。对于这种故障,我们一般可以通过PING命令,和tracert命令等查看的出来。2、对于蠕虫病毒的查找,在科来网络分析系统中,可以首先查看以下参数:TCP数据包、TCP连接、网络连接及会话,对应的分析视图分别是概要统计、图表、端点以及会话视图。任何一种蠕虫病毒,要在网络中传播,都会具有相同的网络行为特征--扫描,都会产生异常的网络通讯,利用这些行为特征,我们就能够找到感染蠕虫病毒的主机。
原来好使的,升级到最新版,然后就出了这个问题。。特别是信用卡查询,一直都是网络有问题,借记卡就没事。。这APP模块有问题,升级后,没测试就发布出来了
一般来讲,银行的app是绝对没有问题的,原因可能是你没有连接网络或者信号不好

如何将app作为服务器和前端设备通过tcp连接
一般的情况是由后端将数据转换为json格式,然后前端通过ajax获取
不知道

本文由 在线网速测试 整理编辑,转载请注明出处。