Board index » delphi » need help for TClientSocket/TServerSocket programming

need help for TClientSocket/TServerSocket programming

I am new to delphi and I have played with it for about a week.
I wrote a simple client/server chat room program. I use TClientSocket
component to try to logon to the Server. If the server is up then the
two parties can start chatting but if no server avaible the socket is
close and wait another 5 mins then the attemp process again. I though
the client program could run on forever but I found that it gives me an
error message said that the buffer is full or something like that (error
code 10055).  I can simplly free or destroy the socket cause I am
running the process as a loop. What should I do?

helpme

 

Re:need help for TClientSocket/TServerSocket programming


What do you do with the client socket? Each time socket is opened winsock
puts aside a certain amount of buffer space. Ive found in past that this
space isnt released immediately on disconnection.
Noones explained whats happening properly in the past.

I think Ive also had this error (not too sure if this was exact one) when
Ive attempted to write a very large buffer to winsock in a test situation
where I was looking at limits for the socket. Since then I always send data
in small chunks approx 4-8k until buffer is empty or winsock returns -1
(when I wait for onwrite event, using non-blocking sockets)
--
Claire Humphrey
Software Engineer

Quote
"Elton" <leun...@netfront.net> wrote in message

news:MPG.166797ef3c226998968c@news.netfront.net...
Quote
> I am new to delphi and I have played with it for about a week.
> I wrote a simple client/server chat room program. I use TClientSocket
> component to try to logon to the Server. If the server is up then the
> two parties can start chatting but if no server avaible the socket is
> close and wait another 5 mins then the attemp process again. I though
> the client program could run on forever but I found that it gives me an
> error message said that the buffer is full or something like that (error
> code 10055).  I can simplly free or destroy the socket cause I am
> running the process as a loop. What should I do?

> helpme

Re:need help for TClientSocket/TServerSocket programming


Claire <claire.humph...@ntlworld.com> schreef in berichtnieuws
JLcL7.2410$7W5.471...@news11-gui.server.ntli.net...
Quote
> What do you do with the client socket? Each time socket is opened winsock
> puts aside a certain amount of buffer space. Ive found in past that this
> space isnt released immediately on disconnection.
> Noones explained whats happening properly in the past.

[snip]

Perhaps I can explain this Claire...
When a socket is closed, it is put in the so-called TIME_WAIT state.
This is done because delayed packets destined for this socket still may
arrive.
( If this indeed occurs in the TIME_WAIT state, these packets will be
silently discarded)
If the socket ( and hence its port number!) would be immediately reused for
another app, these delayed packets would cause serious havoc, as you can
imagine.
The timeout value for WIN32 is 240 seconds (IIRC); Even on the internet, a
packet would surely have reached its TTL in that period of time.

Regards - Dirk

---------------------------------------------------------
http://www.claessens16.yucom.be
Attention: All spamshields raised; E-mails will bounce!
---------------------------------------------------------

Re:need help for TClientSocket/TServerSocket programming


In article <3bfd665a$0$12225$4d4ef...@news.be.uu.net>, will.bou...@back.com says...

Quote
> Claire <claire.humph...@ntlworld.com> schreef in berichtnieuws
> JLcL7.2410$7W5.471...@news11-gui.server.ntli.net...
> > What do you do with the client socket? Each time socket is opened winsock
> > puts aside a certain amount of buffer space. Ive found in past that this
> > space isnt released immediately on disconnection.
> > Noones explained whats happening properly in the past.

> [snip]

> Perhaps I can explain this Claire...
> When a socket is closed, it is put in the so-called TIME_WAIT state.
> This is done because delayed packets destined for this socket still may
> arrive.
> ( If this indeed occurs in the TIME_WAIT state, these packets will be
> silently discarded)
> If the socket ( and hence its port number!) would be immediately reused for
> another app, these delayed packets would cause serious havoc, as you can
> imagine.
> The timeout value for WIN32 is 240 seconds (IIRC); Even on the internet, a
> packet would surely have reached its TTL in that period of time.

> Regards - Dirk

> ---------------------------------------------------------
> http://www.claessens16.yucom.be
> Attention: All spamshields raised; E-mails will bounce!
> ---------------------------------------------------------

This is such a great newsgroup , people are so helpful.
Ok, currently my loop is running in a 2min interval , I guesss the speed
of the building up of the buffer is faster than the release of it, which
lead to an error. I will make the loop to be 5 mins or up and see.
Thanks.

helpme

Other Threads