views:

143

answers:

4

Hi, I just ventured into writing my first socket based programs in Delphi 2010. I tried with Indy, no success, just even writing a simple client and server that could send packets. Then I used TTCPServer and TTCPClient, same results using the following 'simple as it gets' demos :-

Emmbercadero TTCPServer demo

Emmbercadero TTCPClient demo

I had fired up 2 instances of the IDE for the client and server apps. I was pretty determined to avoid the shame of posting a question related to the socket based version of 'helloworld', and I just spent 2 days trying everything.

Well I just decided to chuck the towel in and ask you guys for help, before i did, I just run the exes from OUTSIDE the IDE... and yeah, they worked! They worked the whole time, but not from inside the IDE.

Can I run these programs inside the IDE sucessfully? Thanks.

+4  A: 

There should be no problems running from inside the IDE. I do it all the time.

Make sure you don't freeze any threads in the debugger, as the server will run in threads.

gbrandt
Thanks. Yes I was starting to think it was down to debegging. I just found that if I ctrl-F9 my server (no breakpoints anywhere) it still does not work, but if I run without debugger Ctrl-shift-F9 it does indeed work from within IDE. Does that tally with your experience?
csharpdefector
Update, Well my server runs ok from IDE without debugger at least, but my other IDE instance for client when run without debugger does not send to server, they do when exes run outside IDE. hmmm
csharpdefector
+2  A: 

TCP/IP programs (of both Client and Server type) can be run safely from the Delphi IDE.

The only concern could be about your FireWall settings, but it could be no problem to allow your program to have network access.

During debugging, if you make step-by-step (F7/F8 keys), only one thread is running, so any background thread (like the Server thread) won't run.

You must launch the Server before running the Client, by design.

I never used the TTCPClient and TTCPServer classes, which I found out to be buggy... try with another framework, like Indy, Synapse or our SynCrtSock.

Which Delphi IDE version are you running? On which Operating System?

A.Bouchez
+1 for mentioning the possibility of a local firewall causing problems.
Frank Shearar
D2010, XP Pro SP2. Indeed, I think I will use Indy. Yes I had already considered firewall, I dont think that is it, but I will disable it completely and triple check.
csharpdefector
A: 

I had similar problems when deploying a datasnap server and client. The problem I had was that the DSServer was already running and the port was in use. So make sure you check all your ports and whether your connections are active in the IDE and also in the running apps.

Matt
+1  A: 

Thanks for all your help. I just found the solution to my problem...

I had some time ago installed a trial of a program called Diamond Port Explorer which had since expired. When I was trying to get a simple Indy TIdTCPServer working I was getting error 10146 (or 10106 can't remember) which was 'failed to initialise'. I also nocticed the the Ide event log a module unload occurred at the point I tried to set TIdTCPServer.Active:= true on dcsws2.dll - which is a dll from Diamond PortExplorer (which was not actually running).

So I uninstalled Diamond PortExplorer, and now I have no problem!

csharpdefector