开发者

Best way to make Flex 4 connect to a custom server?

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! :)


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜