Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jun : Re: IdTCPServer
| Subject: | Re: IdTCPServer |
| Posted by: | "brandon" (someo..@microsoft.com) |
| Date: | Thu, 8 Jun 2006 16:25:17 |
Sorry, allow me to elaborate ...
The server is actually the Indy sample that came with Delphi 6. I did little
or no modifiaction to the server sample that was shipped.
The client was also based on the Indy sample. I have made modification to to
it only to handle different message types (Private, Global, Internal...)
The IdTCPClient is installed in TfrmCommunicator in my main application.
The actual error appears to be that when a client session terminates in an
"unclean" manner, the server becomes unstatble. By that I mean, it appears
that the next user to attempt to connect gets the "Socket Error # 0"
message.
Starting at the botom of the call stack and working up, the first line of
code that belongs to me is line 213:
if not IdTCPClient1.Connected then IdTCPClient1.Connect(10);
As stated above, it appears that the server has become unstable when a user
terminates the session without allowing the application to issue a clean
disconnect. Subsequent attempts by the offending user or other users
attempting to attach to the server raise the connection error at the client
end.
I am only speculating with regard to the server being "unstable", it is only
an observation of a person with limited exposure to Indy. There are no error
messages at the server when the clients receive the error. There is a
listbox at the server that shows which users are logged into the server, I
have seen ASCII characters in this box as well as the user name "Logging
in...". If it helps, can attach the server code in another post for review,
it is only 550 lines of code.
As far as using the IRC components, it is not my intention to provide an IRC
chat, the messaging is really intended to be an internal (to the
application) communication tool. A side effect of these components is that
there is some application specific chat capabilites available. In no way
shape or form are we attempting to reach out across the internet and hook
into any other IRC servers or allow acess to the internal messaging system
by other IRC clients.
tia...brandon
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:44887433$3@newsgroups.borland.com...
>
> "brandon" <someone@microsoft.com> wrote in message
> news:448869e3@newsgroups.borland.com...
>
>> I have an app that are using a IdTCPClient(v9.0.14) and
> IdTCPServer(v9.0.14)
>
> The current snapshot version is 9.0.50. You should consider upgrading to
> make sure you have all of the latest bug fixes.
>
>> to handle some messaging between peers(simple IRC).
>
> Any reason why you are not using TIdIRC and TIdIRCServer?
>
>> Occasionally, the server will not allow clients to connect and
>> gives the following error:
>>
>> Exception 'EIdSocketError' in module XXX.exe at 0020537B
>> Socket Error # 0
>>
>> Source file: IdStack.pas, Line 223
>>
>> Call stack:
>> :Idstack.TIdStack.RaiseSocketError (IdStack.pas, line 223)
>> :Idtcpconnection.TIdTCPConnection.WriteBuffer (IdTCPConnection.pas, line
>> 799)
>> :Idtcpconnection.TIdTCPConnection.Write (IdTCPConnection.pas, line 762)
>> :Frm_communicator.TfrmCommunicator.btnRefreshClick (frm_communicator.pas,
>> line 213)
>
> That call stack does not match the code you have shown. Not only that,
> but
> your call stack is incomplete anyway, since there is a lot more going
> between Write() and RaiseSocketError() that you haven't shown. Neither
> Connect() nor Connected() of TIdTCPClient ever call
> TIdTCPConnection.Write()
> anyway. The only way Write/WriteBuffer() could be throwing the exception
> is
> if Connect() is actually successful and then the exception occurs in your
> call to WriteLn() instead. Which is a very different issue then you have
> described.
>
>> Restarting the server app fixes the problem, but does not explain
>> why it occured in the first place.
>
> There is no way to diagnose the problem given the minimal details you have
> provided so far. Especially since you did not show your server code.
> What
> is probably happening is that the server is disconnecting the socket
> before
> the client can finish writing to it.
>
>
> Gambit