让 Flex 4 连接到自定义服务器的最佳方式?
我制作了一个接受特定端口上的 TCP 连接的自定义服务器。我做了一个相应的客户端,向服务器发送数据。客户端写入套接字,服务器似乎接受它。简而言之,服务器/客户端设备可以正常工作。现在,我只想通过 Flex 4 / Flash Builder 4 重新创建客户端。如何让我的 Flex 4 应用程序连接到我的自定义服务器?
我使用了以下方法:
<fx:Declarations>
<s:HTTPService id="initialConnection"
url="theserverip:theserverport"
resultFormat="text" requestTimeout="5" showBusyCursor="true"
result="initialConnection_resultHandler(event)"
fault="initialConnection_faultHandler(event)" >
</s:HTTPService>
</fx:Declarations>
使用这种类型的方法,服务器似乎根本没有接收到任何连接。而且,即使我将 requestTimeout 设置为 5,我的 Flex 应用程序似乎会不断尝试连接到服务器,因为我对其进行了操纵,以便单击按钮时会调用此 HTTPService 还表明某些按钮将被禁用,并且在连接成功连接、返回错误或超时后它将再次启用。
说了这么多,我想问您,让我的 Flex 应用程序连接到我的定制服务器的最佳方法是什么?另外,我对 Flex 的经验并不丰富,所以请尝试详细说明答案。
提前致谢! :)
I made a custom server that accepts TCP connections on a certain port. I made a corresponding client that sends data to the server. The client writes to the socket and the server seems to accept it. In short, the server / client rig works. Now I want to re-create the client only this time, via Flex 4 / Flash Builder 4. How do I go about making my Flex 4 app connect to my custom server?
I used the following approach:
<fx:Declarations>
<s:HTTPService id="initialConnection"
url="theserverip:theserverport"
resultFormat="text" requestTimeout="5" showBusyCursor="true"
result="initialConnection_resultHandler(event)"
fault="initialConnection_faultHandler(event)" >
</s:HTTPService>
</fx:Declarations>
With that type of approach, the server doesn't seem to be receiving any connections at all. And also, even though I set the requestTimeout to 5, my Flex app seems to continuously try to connect to the server because I rigged it so that the button when clicked will call this HTTPService also that certain button would get disabled and it will get enabled again after it the connection successfully connects, returned an error or if it timed out.
So with all these said, I want to ask you, what is the best approach to making my Flex app connect to my custom made server? Also I'm not really experienced with Flex so please try to elaborate on the answer.
Thanks in advance! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您编写了一个在特定端口上接受 TCP 连接的自定义服务器,您可能不想使用专门发送 HTTP 请求的 HTTPService。根据您的帖子,我假设您的自定义服务器不知道如何处理 HTTP 请求。
我建议查看 套接字 及其用途在 Flash Player 中使用。由于您已经有了一个可用的客户端,我希望将其转换为 ActionScript 应该不会太难。我的冲动是,如果您可以在不依赖任何 Flex 框架的情况下实现客户端库,从长远来看,您的情况会更好。
尽管如此,我怀疑在 99% 的情况下,可能不需要从头开始构建自己的服务器和客户端。有很多现有的服务器产品提供了多种来回获取数据的方法。
If you wrote a custom server that accepts TCP connections on a specific port, you probably don't want to use HTTPService, which specifically send HTTP Requests. Based on your post, I assume your custom server would not know what to do with an HTTP Request.
I suggest looking into sockets and how they are used in the Flash Player. Since you already have a working client, I would expect it shouldn't be too hard to convert it to ActionScript. My impulse is that if you can implement your client library without any Flex framework dependencies you'll be better off in the long term.
All that said, I'd suspect that in 99% of the case, building your own server--and client--from scratch is probably not needed. There are plenty o existing server products that provide plenty of ways to get data back and forth.
在Flex 4 with PHP中,我们可以通过简单的拖放轻松使用MySQL操作,在badend上flex会自动生成php的代码,我们可以对其进行修改。
问题是,我的要求是在PHP中连接SQL Server 2000与Flex 4,我尝试修改flex制作的类,我将mysql_connect更改为mssql_connect,所有功能都相同,但出现问题,返回速度非常慢缓慢,并且我无法正确获取数据,页面需要花费大量时间来加载,并且加载时,数据呈分散形式。请告诉我,是否有办法连接 flex php 和 sql server 2000。
问候
阿蒂夫
In Flex 4 with PHP, we can use MySQL operations easily with simple drag and drop, on the badend flex auto generates the code for php and we can modify it.
Question is, my requirement is to connect SQL server 2000 with Flex 4 in PHP, i have tried to modify the class made by flex, i changed mysql_connect to mssql_connect, same case with all functions, but the problem occured, the returning speed is very slow, and i dont get data correctly, page takes a lot of time to load and when it is loaded, data is in scattered form. Please let me know, is there anyway to connect flex php and sql server 2000.
Regards
Atif