473,569 Members | 2,984 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Socket TCP questiuon.

If you send data using TCP and Socket, can the client then be 100% sure that
if it send´s data and no exception uccur, then the data will also arrived in
a a correct way on the server.

What if e.g. some router on the way has restarted or if it restarts just in
the same time as the data is beeing send.

?
Nov 15 '05 #1
6 2533
Hi Anders!

"Anders Both" <an********@hot mail.com> schrieb im Newsbeitrag
news:O5******** ******@TK2MSFTN GP09.phx.gbl...
If you send data using TCP and Socket, can the client then be 100% sure that if it send´s data and no exception uccur, then the data will also arrived in a a correct way on the server. What if e.g. some router on the way has restarted or if it restarts just in the same time as the data is beeing send.


If you use UDP, then your application must handle these things.
If you use TCP, then the System itself is doing the whole work for you.
(e.g. sending parts of your data in packages, waiting for an
acknowkledge-message, resending data if a packet is lost ...

If everything clear now, or do you need more details? Or do you have a
concrete problem that should be solved?

With kind regards,

Konrad
Nov 15 '05 #2
OK, Thx. I will look deper in to it.

Best Regards

Anders Both

"Konrad Neitzel" <ne*****@neitze l.de> wrote in message
news:OI******** ******@TK2MSFTN GP12.phx.gbl...
Hi Anders!

"Anders Both" <an********@hot mail.com> schrieb im Newsbeitrag
news:O5******** ******@TK2MSFTN GP09.phx.gbl...
If you send data using TCP and Socket, can the client then be 100%

sure that
if it send´s data and no exception uccur, then the data will also

arrived in
a a correct way on the server.

What if e.g. some router on the way has restarted or if it restarts

just in
the same time as the data is beeing send.


If you use UDP, then your application must handle these things.
If you use TCP, then the System itself is doing the whole work for you.
(e.g. sending parts of your data in packages, waiting for an
acknowkledge-message, resending data if a packet is lost ...

If everything clear now, or do you need more details? Or do you have a
concrete problem that should be solved?

With kind regards,

Konrad

Nov 15 '05 #3
I am back already.

But what if you have a socket connection between a client and a server. And
the server sometimes send´s some data to the client, like lets say every 5
minute, and the client is just waiting to reseive this data. What if the
server frezzes or if the connection is lost in some way, how (if it is
alerted) will the client then be allerted when using asynchronous Sockets
(TCP).

Best Regards Anders Both

"Konrad Neitzel" <ne*****@neitze l.de> wrote in message
news:OI******** ******@TK2MSFTN GP12.phx.gbl...
Hi Anders!

"Anders Both" <an********@hot mail.com> schrieb im Newsbeitrag
news:O5******** ******@TK2MSFTN GP09.phx.gbl...
If you send data using TCP and Socket, can the client then be 100%

sure that
if it send´s data and no exception uccur, then the data will also

arrived in
a a correct way on the server.

What if e.g. some router on the way has restarted or if it restarts

just in
the same time as the data is beeing send.


If you use UDP, then your application must handle these things.
If you use TCP, then the System itself is doing the whole work for you.
(e.g. sending parts of your data in packages, waiting for an
acknowkledge-message, resending data if a packet is lost ...

If everything clear now, or do you need more details? Or do you have a
concrete problem that should be solved?

With kind regards,

Konrad

Nov 15 '05 #4
Hi Anders!

"Anders Both" <an********@hot mail.com> schrieb im Newsbeitrag
news:ua******** ********@TK2MSF TNGP09.phx.gbl. ..
But what if you have a socket connection between a client and a server. And the server sometimes send´s some data to the client, like lets say every 5 minute, and the client is just waiting to reseive this data. I think, that it is recommend to send some dummy stuff like "pings"
through this connection. (Or this is the way, I am going on -> server
side <- to be sure, that all clients are still alive ...
What if the
server frezzes or if the connection is lost in some way, how (if it is
alerted) will the client then be allerted when using asynchronous Sockets (TCP).


I haven't tested this stuff until now. If the server didn't respond,
because simply a thread is locked, then you will not recognize it. But
the connection should be closed, if the server crashes or there will be
a network problem for some time ... But as I told you: I am not that
sure - You had to test that a little first!

If you need multiple clients to connect to a server and simply get some
information every 5 mins: Ever thought about remoting? Then all you have
to do is calling a function in an Remote Object .... That could be much
better and much easier than building a tcp/ip solution on your own.

With kind regards,

Konrad
Nov 15 '05 #5
Thx,

I can not use remoting, because the connection has to be from a java client
on a web-page to a c# service.

But I will find out everything.

Thx alot.

"Konrad Neitzel" <ne*****@neitze l.de> wrote in message
news:er******** *****@TK2MSFTNG P09.phx.gbl...
Hi Anders!

"Anders Both" <an********@hot mail.com> schrieb im Newsbeitrag
news:ua******** ********@TK2MSF TNGP09.phx.gbl. ..
But what if you have a socket connection between a client and a

server. And
the server sometimes send´s some data to the client, like lets say

every 5
minute, and the client is just waiting to reseive this data.

I think, that it is recommend to send some dummy stuff like "pings"
through this connection. (Or this is the way, I am going on -> server
side <- to be sure, that all clients are still alive ...
What if the
server frezzes or if the connection is lost in some way, how (if it is
alerted) will the client then be allerted when using asynchronous

Sockets
(TCP).


I haven't tested this stuff until now. If the server didn't respond,
because simply a thread is locked, then you will not recognize it. But
the connection should be closed, if the server crashes or there will be
a network problem for some time ... But as I told you: I am not that
sure - You had to test that a little first!

If you need multiple clients to connect to a server and simply get some
information every 5 mins: Ever thought about remoting? Then all you have
to do is calling a function in an Remote Object .... That could be much
better and much easier than building a tcp/ip solution on your own.

With kind regards,

Konrad

Nov 15 '05 #6
"Anders Both" <an********@hot mail.com> wrote in
news:#4******** ******@tk2msftn gp13.phx.gbl:
Thx,

I can not use remoting, because the connection has to be from a java
client on a web-page to a c# service.

But I will find out everything.

Thx alot.

"Konrad Neitzel" <ne*****@neitze l.de> wrote in message
news:er******** *****@TK2MSFTNG P09.phx.gbl...
Hi Anders!

"Anders Both" <an********@hot mail.com> schrieb im Newsbeitrag
news:ua******** ********@TK2MSF TNGP09.phx.gbl. ..
> But what if you have a socket connection between a client and a

server. And
> the server sometimes send´s some data to the client, like lets say

every 5
> minute, and the client is just waiting to reseive this data.

I think, that it is recommend to send some dummy stuff like "pings"
through this connection. (Or this is the way, I am going on -> server
side <- to be sure, that all clients are still alive ...
> What if the
> server frezzes or if the connection is lost in some way, how (if it
> is alerted) will the client then be allerted when using
> asynchronous

Sockets
> (TCP).


I haven't tested this stuff until now. If the server didn't respond,
because simply a thread is locked, then you will not recognize it.
But the connection should be closed, if the server crashes or there
will be a network problem for some time ... But as I told you: I am
not that sure - You had to test that a little first!

If you need multiple clients to connect to a server and simply get
some information every 5 mins: Ever thought about remoting? Then all
you have to do is calling a function in an Remote Object .... That
could be much better and much easier than building a tcp/ip solution
on your own.

With kind regards,

Konrad



Anders,

You may have already found an answer for this, if not, hopefully this
helps.
The only way the client can know that the connection is gone, is if the
connection is closed by the server, or the client tries to send a data
packet, but hits its timeout period on the send method.

If the connection is lost, for example a router dies, then the only way to
know the connection is gone, is from a timeout, as you will never get the
shutdown (fin) message from the socket that initiated the shutdown/close.

You have two simple options that I can think of off the top of my head.

You can make the clients repond to the servers data, and have the
SendTimeout option set on the client sockets.
Below is from the MSDN help.

// Send operations will time-out if confirmation
// is not received within 1000 milliseconds.
s.SetSocketOpti on (SocketOptionLe vel.Socket, SocketOptionNam e.SendTimeout,
1000);
Your other options is if the server is known to always send data at a
specific interval, then you can use a timer to watch for a missed packet.
Or you can send Keep-Alive messages every 10 seconds, if the data is not
regular enough, or you don't want the sockets locked for longer than
necessary with a lost connection.

So if the server sends "Alive" every 5 seconds, then set a timer's timeout
period to 10 seconds. Whenever any data arrives on the socket, reset the
timer. If the timers Elapsed event is raised, then you know the server is
possibly not responding.

For more detail on Socket programming for C#, you can not go past Richard
Blum's book "C# Network Programming" - published by Sybex.
Scott Gaitskell
Nov 15 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
16599
by: Chuck E. Cheese | last post by:
I need a php page to connect to a python created socket and sent and receive data. below is the python code which opens a socket on the localhost @ port 21567: #!/usr/bin/python2 from socket import * from time import time,ctime HOST ='127.0.0.1' PORT = 21567
8
9271
by: simon place | last post by:
Spent some very frustrating hours recoding to find a way of closing a server socket, i'd not thought it would be any problem, however, after complete failure and as a last resort, i looked at the python wrapper module for sockets, and found that the close command doesn't actually call the underlying close! this didn't seem right, so i added...
3
2642
by: Thomas Hervé | last post by:
My problem is not really python specific but as I do my implementation in python I hope someone here can help me. I have two programs that talk through a socket. Here is the code : <server> sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.settimeout(5.0)
4
8712
by: DreJoh | last post by:
I've read many articles on the subject and the majority of them give the same solution that's in article 821625 on the MSDN website. I'm using the following code and when a the client disconnects the child socket remains in the CLOSE_WAIT state. Anyone have any idea what's missing? ----------------------------- Socket Code...
4
18097
by: Chris Tanger | last post by:
Context: C# System.Net.Sockets Socket created with constructor prarmeters Internetwork, Stream and TCP everything else is left at the default parameters and options except linger may be changed as I find appropriate. I am using the socket asynchronously by calling the BeingSend and BeginReceive calls. I would like to be able to call...
0
4660
by: Macca | last post by:
Hi, I am writing an asychronous socket server to handle 20+ simulataneous connections. I have used the example in MSDN as a base. The code is shown at end of question. Each connection has a number of different types of data coming in. I have a databuffer for each type of data coming in.
3
4277
by: BuddyWork | last post by:
Hello, Could someone please explain why the Socket.Send is slow to send to the same process it sending from. Eg. Process1 calls Socket.Send which sends to the same IP address and port, the receiver is running within Process1. If I move the receiver into Process2 then its fast. Please can someone explain.
5
12760
by: darthghandi | last post by:
I've created a class to listen to all interfaces and do a BeginAccept(). Once it gets a connection, it passes the connected socket off and stores it in a List. Next, it continues to listen for more incoming connections and does the BeginAccpet() again. It does an infinite loop this way. My question is: What is the best way to stop this? ...
4
16065
by: O.B. | last post by:
I have a socket configured as TCP and running as a listener. When I close socket, it doesn't always free up the port immediately. Even when no connections have been made to it. So when I open the socket again, the bind fails because the port is still in use. When I execute the code in "debug" mode, the problem never occurs. When I...
1
7681
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6290
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5228
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3662
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.