dotnet remoting:
Hi everybody, I'm trying to build an application msn like to play chess with my friends. I have almost done everything, I have the chat form, and it works pretty good. To do this, I use TcpListener and TcpClient, threads and a ChatMessage serializable class that contains the body of a message. I use a binary formatter to send informations on the networkstream. So, it works fine, but I have wondered how to check if the TcpConnection is still alive. Many of my friends have some problems with the adls and sometimes they disconnect for a while, this implies changing the ip and also that I can't use the TcpClient and networkstream associated any more because they are no longer bound to my friend's application. So what I need to know is this (and sry but I have spent days searching for informations on the net but I was unable to find them...) 1- how to know if my tcp connection is alive when I'm willing to send some data? 2- How to handle it? I mean, do I have to create a tcpclient everytime I receive a connecting attempt or do I have to first init a tcpClient and them use it for the whole time I'm going to be connected with my friend? 3- do I need to send a packet over the connection at regular intervals in order not to let it die or it's fine to leave it on its own? 4- using UDP would be easier, I just would have to care about having a crc and an ACK system to send and receive packets, but is it possible to serialize objects using UDP? thank you to anybody that will help, Romano Fabrizio sfabriz@zerovolt.com
[quoted text, click to view] Fabrizio Romano wrote: > Hi everybody, > I'm trying to build an application msn like to play chess with my friends. > I have almost done everything, I have the chat form, and it works pretty > good. > To do this, I use TcpListener and TcpClient, threads and a ChatMessage > serializable class that contains the body of a message. > > I use a binary formatter to send informations on the networkstream. > > So, it works fine, but I have wondered how to check if the TcpConnection is > still alive. > Many of my friends have some problems with the adls and sometimes they > disconnect for a while, this implies changing the ip and also that I can't > use the TcpClient and networkstream associated any more because they are no > longer bound to my friend's application. > > So what I need to know is this (and sry but I have spent days searching for > informations on the net but I was unable to find them...) > > 1- how to know if my tcp connection is alive when I'm willing to send some > data?
try to send something and you'll get an exception, no? [quoted text, click to view] > 2- How to handle it? I mean, do I have to create a tcpclient everytime I > receive a connecting attempt or do I have to first init a tcpClient and them > use it for the whole time I'm going to be connected with my friend?
well yes, i guess that's what you're already doing by now (?) usual thing is to have your app running in a thread, the server in a thread and create a new thread for every client that connects. your problem will be to get the state back to where it was when the connection brakes and they are connecting again (identify the other, see what was the last information he got and send everything he needs to be up to date) [quoted text, click to view] > 3- do I need to send a packet over the connection at regular intervals in > order not to let it die or it's fine to leave it on its own?
dont think so. if both are alive the connection will also be. if one goes down you will see it as soon as you try to send something, or he tries to reconnect. [quoted text, click to view] > 4- using UDP would be easier, I just would have to care about having a crc > and an ACK system to send and receive packets, but is it possible to > serialize objects using UDP?
well, not definitly sure about this but just looking through msdn didn't give me any hint about if it's possible to get a stream from an UdpClient, so i dont think you can do it.
Oh yes, I very well know this, I have done a FTP like application in java with congestion window and dinamic traffic control using udp, cumulative acks and so on. The problem here is basically this one, using TCP lets me use also serialization which is great because I don't have to worry about transforming data into a byte array, make the crc, split in more packets if I need, checking for ack when a certain packet is received and, when I receive the whole message, build it up by unpacking the udp datagrams. I really was hoping to find a solution with tcp control. It's more reliable and very easy to use and I don't have problems to forward the messages to the correct chat window in case of multiple chat windows opened. What i need is a way to check if my TCP connection is alive and working, or to know if I can use serialization with upd. Regards, fabrizio Romano Fabrizio Tel: +39 347/4888390 sfabriz@zerovolt.com "Dan Kelley" <DanKelley@discussions.microsoft.com> ha scritto nel messaggio news:C333AE5A-CA87-46E2-BBCE-37FA91A6CBB2@microsoft.com... [quoted text, click to view] >I can't help you with you TCP questions. However, you could certainly use >UDP > in this instance. You can send data over a UDP socket in the same way you > can > using TCP/IP. > > As it seems you know, the UDP protocol does not guarantee the delivery of > messages OR the order they are delivered in, unlike TCP/IP. Therefore, as > well as ACKs, you may need to also include a message sequence number as > well, > and be able to handle the situation where messages are received out of > sequence, or don't arrive. > > HTH > Dan > > "Fabrizio Romano" wrote: > >> Hi everybody, >> I'm trying to build an application msn like to play chess with my >> friends. >> I have almost done everything, I have the chat form, and it works pretty >> good. >> To do this, I use TcpListener and TcpClient, threads and a ChatMessage >> serializable class that contains the body of a message. >> >> I use a binary formatter to send informations on the networkstream. >> >> So, it works fine, but I have wondered how to check if the TcpConnection >> is >> still alive. >> Many of my friends have some problems with the adls and sometimes they >> disconnect for a while, this implies changing the ip and also that I >> can't >> use the TcpClient and networkstream associated any more because they are >> no >> longer bound to my friend's application. >> >> So what I need to know is this (and sry but I have spent days searching >> for >> informations on the net but I was unable to find them...) >> >> 1- how to know if my tcp connection is alive when I'm willing to send >> some >> data? >> 2- How to handle it? I mean, do I have to create a tcpclient everytime I >> receive a connecting attempt or do I have to first init a tcpClient and >> them >> use it for the whole time I'm going to be connected with my friend? >> 3- do I need to send a packet over the connection at regular intervals in >> order not to let it die or it's fine to leave it on its own? >> 4- using UDP would be easier, I just would have to care about having a >> crc >> and an ACK system to send and receive packets, but is it possible to >> serialize objects using UDP? >> >> thank you to anybody that will help, >> >> Romano Fabrizio >> sfabriz@zerovolt.com >> >> >>
I can't help you with you TCP questions. However, you could certainly use UDP in this instance. You can send data over a UDP socket in the same way you can using TCP/IP. As it seems you know, the UDP protocol does not guarantee the delivery of messages OR the order they are delivered in, unlike TCP/IP. Therefore, as well as ACKs, you may need to also include a message sequence number as well, and be able to handle the situation where messages are received out of sequence, or don't arrive. HTH Dan [quoted text, click to view] "Fabrizio Romano" wrote: > Hi everybody, > I'm trying to build an application msn like to play chess with my friends. > I have almost done everything, I have the chat form, and it works pretty > good. > To do this, I use TcpListener and TcpClient, threads and a ChatMessage > serializable class that contains the body of a message. > > I use a binary formatter to send informations on the networkstream. > > So, it works fine, but I have wondered how to check if the TcpConnection is > still alive. > Many of my friends have some problems with the adls and sometimes they > disconnect for a while, this implies changing the ip and also that I can't > use the TcpClient and networkstream associated any more because they are no > longer bound to my friend's application. > > So what I need to know is this (and sry but I have spent days searching for > informations on the net but I was unable to find them...) > > 1- how to know if my tcp connection is alive when I'm willing to send some > data? > 2- How to handle it? I mean, do I have to create a tcpclient everytime I > receive a connecting attempt or do I have to first init a tcpClient and them > use it for the whole time I'm going to be connected with my friend? > 3- do I need to send a packet over the connection at regular intervals in > order not to let it die or it's fine to leave it on its own? > 4- using UDP would be easier, I just would have to care about having a crc > and an ACK system to send and receive packets, but is it possible to > serialize objects using UDP? > > thank you to anybody that will help, > > Romano Fabrizio > sfabriz@zerovolt.com > >
Thank you! sfabriz Romano Fabrizio sfabriz@zerovolt.com "Paul Wohlhart" <pwoh@mega.ist.utl.pt> ha scritto nel messaggio news:%23RFFbMATFHA.3936@TK2MSFTNGP15.phx.gbl... [quoted text, click to view] > Fabrizio Romano wrote: >> Hi everybody, >> I'm trying to build an application msn like to play chess with my >> friends. >> I have almost done everything, I have the chat form, and it works pretty >> good. >> To do this, I use TcpListener and TcpClient, threads and a ChatMessage >> serializable class that contains the body of a message. >> >> I use a binary formatter to send informations on the networkstream. >> >> So, it works fine, but I have wondered how to check if the TcpConnection >> is still alive. >> Many of my friends have some problems with the adls and sometimes they >> disconnect for a while, this implies changing the ip and also that I >> can't use the TcpClient and networkstream associated any more because >> they are no longer bound to my friend's application. >> >> So what I need to know is this (and sry but I have spent days searching >> for informations on the net but I was unable to find them...) >> >> 1- how to know if my tcp connection is alive when I'm willing to send >> some data? > > try to send something and you'll get an exception, no? > >> 2- How to handle it? I mean, do I have to create a tcpclient everytime I >> receive a connecting attempt or do I have to first init a tcpClient and >> them use it for the whole time I'm going to be connected with my friend? > > well yes, i guess that's what you're already doing by now (?) > usual thing is to have your app running in a thread, the server in a > thread and create a new thread for every client that connects. > > your problem will be to get the state back to where it was when > the connection brakes and they are connecting again (identify the > other, see what was the last information he got and send everything > he needs to be up to date) > >> 3- do I need to send a packet over the connection at regular intervals in >> order not to let it die or it's fine to leave it on its own? > > dont think so. if both are alive the connection will also be. if one > goes down you will see it as soon as you try to send something, or > he tries to reconnect. > >> 4- using UDP would be easier, I just would have to care about having a >> crc and an ACK system to send and receive packets, but is it possible to >> serialize objects using UDP? > > well, not definitly sure about this but just looking through msdn didn't > give me any hint about if it's possible to get a stream from an UdpClient, > so i dont think you can do it. > > paul
Don't see what you're looking for? Try a search.
|