473,396 Members | 1,764 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,396 software developers and data experts.

System.Net.Sockets.Socket.Blocking = True doesn't work

In news:OZ**************@TK2MSFTNGP10.phx.gbl... I ask the question how I
can see if all the data is on the other side of the connection.
I got as answer that I should use the blocking property.
I tried this I don't see any diffents, I am sending 10Mb and the
Send/BeginSend command doesn't wait till the data is on the remotepoint.
Can somebody pls. explain this.

Regards Robert.
Nov 15 '05 #1
3 3665
"Robert A. van Ginkel" <ro****@stylegate.com> wrote in message news:<#V**************@TK2MSFTNGP09.phx.gbl>...
In news:OZ**************@TK2MSFTNGP10.phx.gbl... I ask the question how I
can see if all the data is on the other side of the connection.
I got as answer that I should use the blocking property.
I tried this I don't see any diffents, I am sending 10Mb and the
Send/BeginSend command doesn't wait till the data is on the remotepoint.
Can somebody pls. explain this.

Robert -

Whether you are using synchronous or asynchronous sockets, there
is no possible way for one end of the connection to know that it has
received all of the data unless it is told by the other end of the
connection. With TCP, there is no guarantee that all of the data will
arrive in a steady stream. There are often delays between packets as
they are sent on the network. This causes the Receive() method to
assume the data stream is complete and finish the call. It is the
receiving program's job to determine if there is really more data to
be read. There are two common techniques to do this:

If only one data stream is sent between the two sides, then the
sending side can close the socket when it is finished sending bytes.
The receiving side can then read data until the Recieve() method
returns 0 bytes, indicating that the connection was closed, and all of
the data was received.

If you must leave the connection active after the data stream, the
best way to determine if all of the data is received is by having the
sending side first send the size of the data to the receiving side,
then send the actual data. The receiving side can then loop on the
Receive() methods (either sync or async) until it knows all of the
data has been received (by keeping track of the number of bytes
received).

Hope this helps shed some light on your problem.

Rich Blum - Author
"C# Network Programming" (Sybex)
http://www.sybex.com/sybexbooks.nsf/Booklist/4176
"Network Performance Open Source Toolkit" (Wiley)
http://www.wiley.com/WileyCDA/WileyT...471433012.html
Nov 15 '05 #2
Dear Mr. Blum,

Thank you for responding.

First of all you explain that Localpoint never knows if Remotepoint has
received all the data, only if Remotepoint confirms this in sending a TCP/IP
package back.
I disagree, thats more UDP/IP, in TCP/IP socket there is an engine that
makes sure u receive/send the packages or else there is a socket error.
While TCP/IP is a async protocol, in a socket there is a mechanism that
keeps track of sequence and what was/wasn't send, bottomline: if a packet is
lost it is being send again.
Sample case:
if u send 1 byte from a client in Canada to a server in Australia with a 28k
modem thats being shared by an office of 30 people connected to the slowest
profider. (etc.)
What I want to say is that 1 byte may take 1 minute, and I use 1 byte as an
example because I don't want to make a discussion

There are three stadiums(simplified):
A My object sends to the Winsock, (buffer is being fed, no data on the
network, no data on the remote point)
B Winsock processes his buffer and sends on the network (buffer is empty,
data on the network, no data on the remote point)
C All data is correctly processed and transported (buffer is empty, no data
on the network,data on the remote point)

I achieve (A) ofcourse, I would really want to know (C), but I would be
satisfied with (B).
I know (B) can be achieved, I hope (C) is too.

P.S. I know of lingering and all other socket options, but at this point I
am not intrested in that, I just want to know why Socket.Blocking doesn't
work. If I send 10Mb over the socket with or without blocking mode, it
transmits my data to the socket buffer, and thats all, thats (A). I couldn't
find it in the FrameWork so I read the winsock API but couldn't find a
function I could use.

Regards,
Robert

"Rich Blum" <ri*******@juno.com> schreef in bericht
news:cc*************************@posting.google.co m...
"Robert A. van Ginkel" <ro****@stylegate.com> wrote in message

news:<#V**************@TK2MSFTNGP09.phx.gbl>...
In news:OZ**************@TK2MSFTNGP10.phx.gbl... I ask the question how I can see if all the data is on the other side of the connection.
I got as answer that I should use the blocking property.
I tried this I don't see any diffents, I am sending 10Mb and the
Send/BeginSend command doesn't wait till the data is on the remotepoint.
Can somebody pls. explain this.

Robert -

Whether you are using synchronous or asynchronous sockets, there
is no possible way for one end of the connection to know that it has
received all of the data unless it is told by the other end of the
connection. With TCP, there is no guarantee that all of the data will
arrive in a steady stream. There are often delays between packets as
they are sent on the network. This causes the Receive() method to
assume the data stream is complete and finish the call. It is the
receiving program's job to determine if there is really more data to
be read. There are two common techniques to do this:

If only one data stream is sent between the two sides, then the
sending side can close the socket when it is finished sending bytes.
The receiving side can then read data until the Recieve() method
returns 0 bytes, indicating that the connection was closed, and all of
the data was received.

If you must leave the connection active after the data stream, the
best way to determine if all of the data is received is by having the
sending side first send the size of the data to the receiving side,
then send the actual data. The receiving side can then loop on the
Receive() methods (either sync or async) until it knows all of the
data has been received (by keeping track of the number of bytes
received).

Hope this helps shed some light on your problem.

Rich Blum - Author
"C# Network Programming" (Sybex)
http://www.sybex.com/sybexbooks.nsf/Booklist/4176
"Network Performance Open Source Toolkit" (Wiley)
http://www.wiley.com/WileyCDA/WileyT...471433012.html

Nov 15 '05 #3
Dear Rich Blum,

I shouldn't control the remotepoint, I work following a specified RFC.

BeginRead,EndRead with his callback sends 0 bytes to close, but I am talking
about sending.
I found the code of .NET framework for unix. And BeginSend uses just a
different thread that invokes the send command.
The networkstream/tcpclient/tcplistener is just a wrapper of the socket. I
am making my own wrapper because, those wrappers are buggy and doesn't give
me propper info.

My question is about blocking, BeginSend with blocking doesn't work (see
documentation of blocking property)
And Send returns imitially, it writes to an internal buffer, And I need to
know when that buffer is empty.
Why? Because If u read my other message 'Socket still
sending?'(news:<#V**************@TK2MSFTNGP09.phx. gbl)
U see I want to start my timeout function after the remotepoint got the
data/after the data is processed in the local winsock buffer.

Regards, Robert

"Rich Blum" <ri*******@juno.com> schreef in bericht
news:cc*************************@posting.google.co m...
"Robert A. van Ginkel" <ro****@stylegate.com> wrote in message

news:<#V**************@TK2MSFTNGP09.phx.gbl>...
In news:OZ**************@TK2MSFTNGP10.phx.gbl... I ask the question how I can see if all the data is on the other side of the connection.
I got as answer that I should use the blocking property.
I tried this I don't see any diffents, I am sending 10Mb and the
Send/BeginSend command doesn't wait till the data is on the remotepoint.
Can somebody pls. explain this.

Robert -

Whether you are using synchronous or asynchronous sockets, there
is no possible way for one end of the connection to know that it has
received all of the data unless it is told by the other end of the
connection. With TCP, there is no guarantee that all of the data will
arrive in a steady stream. There are often delays between packets as
they are sent on the network. This causes the Receive() method to
assume the data stream is complete and finish the call. It is the
receiving program's job to determine if there is really more data to
be read. There are two common techniques to do this:

If only one data stream is sent between the two sides, then the
sending side can close the socket when it is finished sending bytes.
The receiving side can then read data until the Recieve() method
returns 0 bytes, indicating that the connection was closed, and all of
the data was received.

If you must leave the connection active after the data stream, the
best way to determine if all of the data is received is by having the
sending side first send the size of the data to the receiving side,
then send the actual data. The receiving side can then loop on the
Receive() methods (either sync or async) until it knows all of the
data has been received (by keeping track of the number of bytes
received).

Hope this helps shed some light on your problem.

Rich Blum - Author
"C# Network Programming" (Sybex)
http://www.sybex.com/sybexbooks.nsf/Booklist/4176
"Network Performance Open Source Toolkit" (Wiley)
http://www.wiley.com/WileyCDA/WileyT...471433012.html

Nov 15 '05 #4

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

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
1
by: paulbubach | last post by:
Hi @all, we have the following problem. We have developed an application with the Visual Studio.Net 2002 and the project runs on it. But now we have change the version of the Studio and now we...
7
by: Michi Henning | last post by:
Hi, I'm using a non-blocking connect to connect to a server. Works fine -- the server gets and accepts the connection. However, once the connection is established, I cannot retrieve either the...
2
by: Stressed Out Developer | last post by:
We have an application that has a 200 count loop that does the following: ' Each time thru the loop we pass the next IP Address is a range (aka 192.168.4.50 thru 192.168.4.254) Try If...
1
by: Eric Sheu | last post by:
Greetings, I have been searching the web like mad for a solution to my SMTP problem. I am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a web site I have created to...
3
by: J C | last post by:
Hi, I'm using UDPClient to make a simple DNS server. I notice that intermittently and unpredictibly I get: Unhandled Exception: System.Net.Sockets.SocketException: An existing connection...
2
by: jasonsgeiger | last post by:
From: "Factor" <jasonsgeiger@gmail.com> Newsgroups: microsoft.public.in.csharp Subject: Multiple Clients, One port Date: Wed, 19 Apr 2006 09:36:02 -0700 I'm been working with sockets for a...
5
by: Dan Ritchie | last post by:
I've got a client/server app that I used to send large amounts of data via UDP to the client. We use it in various scenarios, one of which includes rendering a media file on the client as it is...
0
by: khu84 | last post by:
Here is client server very simple code, seems to work with telnet but with with web client code gives blank output. Following is the server code:- <?php function...
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: 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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...

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.