BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TClientSocket problems when connecting to server

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
Bo Berglund
Guest





PostPosted: Thu Oct 30, 2003 9:45 pm    Post subject: TClientSocket problems when connecting to server Reply with quote



I have this strange problem:
I have created a class for communicating with a server of our own. It
uses TClientSocket which is created in code. When I use this class in
the test application it works OK but in the big client application it
does not work. The client application is a database app and it has an
ADO connection open to another server where the SQL-Server database
resides.
What happens is this:
First I create the socket: FSocket := TClientSocket.Create(NIL)
Then I set the properties like this:
FSocket.ClientType=nonBlocking
FSocket.Port=something
FSocket.OnConnect, OnDisconnect,OnRead and OnError are set to
handlers.
FSocket.Host is set to the target computer name

Then I have tried both FSocket.Open and FSocket.Active := true.
Both result in a long delay and then the OnError gets fired with an
eeLookup ErrorEvent
The messagetext is: "No such host is known"

But when I use the simple test application using this class the
connection is immediately established running the exact same code....

Also pinging the host in a command window always succeeds.

What should I look out for???

Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Oct 30, 2003 11:03 pm    Post subject: Re: TClientSocket problems when connecting to server Reply with quote




"Bo Berglund" <bo.berglund (AT) mailbox (DOT) swipnet.se> wrote


Quote:
Then I have tried both FSocket.Open and
FSocket.Active := true. Both result in a long delay
and then the OnError gets fired with an eeLookup
ErrorEvent The messagetext is: "No such host is known"

What are you actually setting the Host to? It needs to be a name that is
resolvable via DNS. Otherwise use an IP address with the Address property
instead of Host.

Quote:
But when I use the simple test application using this class
the connection is immediately established running the
exact same code....

Ok, so what are the differences between your main app and the test app?
Does the main app has a message queue? How exactly is the socket class
being used by the two apps?


Gambit



Back to top
Bo Berglund
Guest





PostPosted: Fri Oct 31, 2003 12:06 am    Post subject: Re: TClientSocket problems when connecting to server Reply with quote



On Thu, 30 Oct 2003 15:03:25 -0800, "Remy Lebeau (TeamB)"
<gambit47.no.spam (AT) no (DOT) spam.yahoo.com> wrote:

Quote:
Ok, so what are the differences between your main app and the test app?
Does the main app has a message queue? How exactly is the socket class
being used by the two apps?
Same class handles everything. I just call create on the class and

then the Connect method giving the host as argument (see below).
Quote:


Sorry for waisting the bandwidth...
It turned out that the main app retrieved the host name from the
database (inside a config string) and earlier today the string parsing
had been "fixed" to solve another problem. But it introduced a new bug
so that my actual hostname string became '=host' instead of 'host'.
And this was hidden in my logfiles as well because the host is logged
but the extra = in the log did not show clearly enough. It combined
with the normal = in the log to form a slightly longer ==. I use
Lucida Console font in the editor I examine logs with and this font
melts these two together with no space inbetween....
I have struggled 3-4 hours with this one without getting close to what
was wrong. Sigh...
Now its finally time for bed.

/Bo


Back to top
Martin James
Guest





PostPosted: Fri Oct 31, 2003 12:16 am    Post subject: Re: TClientSocket problems when connecting to server Reply with quote

Quote:
database (inside a config string) and earlier today the string parsing
had been "fixed" to solve another problem. But it introduced a new bug
so that my actual hostname string became '=host' instead of 'host'.
And this was hidden in my logfiles as well because the host is logged
but the extra = in the log did not show clearly enough. It combined
with the normal = in the log to form a slightly longer ==. I use
Lucida Console font in the editor I examine logs with and this font
melts these two together with no space inbetween....
I have struggled 3-4 hours with this one without getting close to what
was wrong. Sigh...

<g> I find a space at the start of a string to be difficult to spot with the
debugger.

Rgds,
Martin



Back to top
hclarius
Guest





PostPosted: Fri Oct 31, 2003 3:33 am    Post subject: Re: TClientSocket problems when connecting to server Reply with quote

Bo Berglund wrote:
Quote:
I have this strange problem:
I have created a class for communicating with a server of our own. It
uses TClientSocket which is created in code. When I use this class in
the test application it works OK but in the big client application it
does not work. The client application is a database app and it has an
ADO connection open to another server where the SQL-Server database
resides.
What happens is this:
First I create the socket: FSocket := TClientSocket.Create(NIL)
Then I set the properties like this:
FSocket.ClientType=nonBlocking
FSocket.Port=something
FSocket.OnConnect, OnDisconnect,OnRead and OnError are set to
handlers.
FSocket.Host is set to the target computer name

Then I have tried both FSocket.Open and FSocket.Active := true.
Both result in a long delay and then the OnError gets fired with an
eeLookup ErrorEvent
The messagetext is: "No such host is known"

But when I use the simple test application using this class the
connection is immediately established running the exact same code....

Also pinging the host in a command window always succeeds.

What should I look out for???


Let me apologize if I am missing something but,
if you just want to connect and interact with SQL Server on an internal
server, why are you using Sockets and ADO? Just use ADO.


Back to top
Bo Berglund
Guest





PostPosted: Fri Oct 31, 2003 6:31 am    Post subject: Re: TClientSocket problems when connecting to server Reply with quote

On Thu, 30 Oct 2003 19:33:09 -0800, hclarius
<hfclarius (AT) nospamcomcast (DOT) net> wrote:

Quote:

Let me apologize if I am missing something but,
if you just want to connect and interact with SQL Server on an internal
server, why are you using Sockets and ADO? Just use ADO.

You *are* missing something Wink
The sockets connection is to a special PC that handles control of a
scanning device. This device must be controlled from several different
client computers on the network. The config data for this device is in
a common SQL database accessed by all clients, from the config string
in the database the PC name and the connection TCP port are extracted.
So the client needs access to the SQL db (via ADO) and then the
scanner server via sockets.
The reason I mentioned ADO was that to my mind this was the only real
difference between the real client software and the socket
communications test program. The ADO connection is done through
TCP/IP, not pipes, so there was a remote possibility for some kind of
interplay here.
However, as usual, the real reason was a *bug* in the decoding
function for the config string retrieved from the database. (Described
in another reply.) The test application of course has edit boxes for
manual entry of these parameters and the data are always right....
/Bo

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.