473,378 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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 2517
Hi Anders!

"Anders Both" <an********@hotmail.com> schrieb im Newsbeitrag
news:O5**************@TK2MSFTNGP09.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*****@neitzel.de> wrote in message
news:OI**************@TK2MSFTNGP12.phx.gbl...
Hi Anders!

"Anders Both" <an********@hotmail.com> schrieb im Newsbeitrag
news:O5**************@TK2MSFTNGP09.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*****@neitzel.de> wrote in message
news:OI**************@TK2MSFTNGP12.phx.gbl...
Hi Anders!

"Anders Both" <an********@hotmail.com> schrieb im Newsbeitrag
news:O5**************@TK2MSFTNGP09.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********@hotmail.com> schrieb im Newsbeitrag
news:ua****************@TK2MSFTNGP09.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*****@neitzel.de> wrote in message
news:er*************@TK2MSFTNGP09.phx.gbl...
Hi Anders!

"Anders Both" <an********@hotmail.com> schrieb im Newsbeitrag
news:ua****************@TK2MSFTNGP09.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********@hotmail.com> wrote in
news:#4**************@tk2msftngp13.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*****@neitzel.de> wrote in message
news:er*************@TK2MSFTNGP09.phx.gbl...
Hi Anders!

"Anders Both" <an********@hotmail.com> schrieb im Newsbeitrag
news:ua****************@TK2MSFTNGP09.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.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.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
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...
8
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...
3
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>...
4
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...
4
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...
0
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...
3
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...
5
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...
4
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.