[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Delphi service server socket

Posted on 2006-04-18
8
Medium Priority
?
1,396 Views
Last Modified: 2010-04-05
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.
0
Comment
Question by:kinnon_2000
  • 4
  • 4
8 Comments
 
LVL 28

Expert Comment

by:2266180
ID: 16476816
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
 

Author Comment

by:kinnon_2000
ID: 16478279
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
 
LVL 28

Expert Comment

by:2266180
ID: 16479716
what socket components do you use in that project? (as it appears I don't have it)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:kinnon_2000
ID: 16479818
I'm using a standard TServer socket component from the Internet palette, and working in Delphi 6.
0
 
LVL 28

Accepted Solution

by:
2266180 earned 2000 total points
ID: 16479945
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
 

Author Comment

by:kinnon_2000
ID: 16481519
Ahh, perfect. thanks very much.
All the best,
Allan.
0
 

Author Comment

by:kinnon_2000
ID: 16481536
additionally, will look into the other alternative networking components you mentioned. many thanks for your help
0
 
LVL 28

Expert Comment

by:2266180
ID: 16481626
no problem, that's what we're here for :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Integration Management Part 2
Loops Section Overview
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question