Delphi service server socket

Hi, I've been using delphi client and server sockets for years and have been pretty happy with the results. I'm writing my first service application, which has a server socket on it. When the service is run however, my client fails to connect. I used a program called active ports to see if my service program is listening, and sure enough, there it is, but with the wrong port number, which I can connect to. At this point, the only place where the port is defined is directly into the port setting in the service sockets component properties, so I'm a bit confused as to why the port is wrong when its running. The port number is different every time.

The server component is threaded, in case that has any baring, though I doubt it because its listening on the wring port before a connection is established. My OS is WinXP.

If anyone can help with this wierd issue, I would be very greatfull.

All the best,
Allan.
kinnon_2000Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

2266180Commented:
I'm afraid we'll need to see a sample code that reproduces that. It's mroe than weird. I wrote 2 service applications during the last months which used sockets and they behive quote nice (using indy). so just make a small service application with just the server socket component which reproduces your issue and we'll take a look at it, In case the small app will not reproduce the issue, it is clearly some programming mistake somewhere, in which case I would very carefully look at the server socket comp. at design time and the code that touches the server socket component to make sure that there are no errors (even that code that uses something like "with socket do with something else do" <- this is more likely to create problems))
0
kinnon_2000Author Commented:
Hi, thanks for the input. I've done as you asked and stripped the app down to just the server socket and a timer to check its listening. you can download the source from

http://www.hebware.co.uk/service_sock_test.zip

This is really crazy. It logs that the port is corect, when reading it from the port property, but telnet wont connect on that port. However, when I use active ports to check the actual listening port, it it different, but can be connected to if the port is set to the actual port it seems to be using.
I've included active ports for convenience as its small and may be a handy little program (and its free).

Any help would be much appreciated.

All the best,
Allan.
0
2266180Commented:
what socket components do you use in that project? (as it appears I don't have it)
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

kinnon_2000Author Commented:
I'm using a standard TServer socket component from the Internet palette, and working in Delphi 6.
0
2266180Commented:
ups. delphi 6 was the key word :) I opened it in delphi 7 and that was the reason of the error :D

ok, so this one was pretty simple :)

you set the "service" property of the socket component to "WorkforceAM". quote from delphi hgelp "For server sockets, using Service rather than Port ensures that the server will listen for TCP/IP requests on the appropriate port."
this means that if service is set, the socket will check with windows for tha port number of the service and use that to connec, disregarding the value of port. now, windows will probably give you a reandom port number if the service name is not found in the list.

just drop that property and you'll be fine.

I will also engourage you to switch to indy or ICS for networking components as they are much more used and supported and of course provide better performance and functionality.

cheers
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kinnon_2000Author Commented:
Ahh, perfect. thanks very much.
All the best,
Allan.
0
kinnon_2000Author Commented:
additionally, will look into the other alternative networking components you mentioned. many thanks for your help
0
2266180Commented:
no problem, that's what we're here for :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.