Re: Who should close and when?
- From: "Alexander Nickolov" <agnickolov@xxxxxxxx>
- Date: Wed, 22 Feb 2006 10:16:48 -0800
Well, that means it's a one shot socket, like HTTP 1.0. BTW,
this shortcoming of HTTP 1.0 was a major reaon for introducing
persistent connections in HTTP 1.1 - it just doesn't scale. Since
you define your own protocol, I suggest you learn from others'
mistakes instead of repeating them...
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Dan" <dvazanias@xxxxxxx> wrote in message
news:uyyfva5NGHA.532@xxxxxxxxxxxxxxxxxxxxxxx
Hi
I am using TCP protocol and not connecting via any standard ports such as
FTP, HTTP etc My app handles the received data by reading the raw bytes
and sends the same etc.
If i send then close the connection my server loses its connection, also
if i receive at the server end then send a reply and use the server to
close the connection the socket is lost for any future data receives.
So i am confused by this. I like the idea of using the closing of the
connection to send the 0 bytes and let me know that the data stream has
ended, its very clean this way. I just dont know the correct way to
implement this method of transmission.
--
Dan
"Vadym Stetsyak" <vadym_s@xxxxxxx> wrote in message
news:uMm5zn4NGHA.428@xxxxxxxxxxxxxxxxxxxxxxx
Hello, Daniel!
D> 6) Now client sends another request to the server but this time i get
a
D> Error writing to the socket as it is disposed (because i closed it)
D> So do i need to create a new socket client side everytime i want to
send
D> some data and you continually open and close sockets? Always closed
from
D> server side?
It depends. If you have protocol that states that after each message you
should close connection, then this behavior is okay ( e.g. HTTP 1.0 )
OTOH you can define the End-Of-Data indicator in your protocol.
Then the algorithm will read up to the that identifier, or will read the
specified number if bytes. Handle the data, and starts receiving next
data part.
D> Should the client ever call the close after it sends?
Must be defined by the protocol you use.
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
.
- References:
- Who should close and when?
- From: Daniel
- Re: Who should close and when?
- From: Dan
- Who should close and when?
- Prev by Date: Re: Communication speed between blocking call and non blocking cal
- Next by Date: Re: WMI/COM and ExecNotificationQueryAsync for Win32_NTLogEvent
- Previous by thread: Re: Who should close and when?
- Next by thread: IPv6 bind with protocol 50 fails
- Index(es):
Relevant Pages
|