Re: Who should close and when?



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




.



Relevant Pages

  • Re: Socket Exception
    ... In this case the server most likely rejected your ... connection. ... Each command is a new socket connection that is opened and closed ... /// Required designer variable. ...
    (microsoft.public.win32.programmer.networks)
  • Re: ASP.NET 2.0 - a newbie question
    ... Is there some experienced ASP.NET 2.0 developer, ... server that comes bundled Microsoft VWDE. ... A connection attempt failed because the ... connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: RPCoHTTP always has 4 failures
    ... ON fast networks, connect using HTTP first, then connect using TCP/IP ... Outlook doesn't even prompt me to log in, it just says the server is ... Warning If you use Registry Editor incorrectly, ... It always shows HTTPS as the protocol in the connection ...
    (microsoft.public.exchange.admin)
  • error when move web service from dev machine to test server
    ... I have a simple web service that I developed on my laptop that resides ... test server, & when I try to run it, I get the error "No connection could be ... No connection could be made because the target machine actively refused it ... Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Messaging alert
    ... I was hopping that I could use sockets to create a connection back and forth in order to send the message. ... I want to be able to send a file name and other information thru the client socket to then process in the servers. ... fileevent $sock w ... At the server side I am listening at the port and execute Accept2 when the socket is created. ...
    (comp.lang.tcl)