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

Answer: 
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](http://livedocs.adobe.com/flex/3/html/help.html?content=17_Networking_and_communications_5.html) 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