473,396 Members | 1,833 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.

Will Socket Send block receive?

Hi,

My understanding is that for the same socket, assuming send and receive run
at two different threads, I have to use BeginReceive to avoid the blocking on
send part. However, I can jsut use Send without worrying about any threading
issue in case send and beginreceive happens at the same time on the socket?
Am I correct on this?

Thanks

Chris
Jun 27 '08 #1
4 5269
On Thu, 19 Jun 2008 12:27:02 -0700, chrisben
<ch******@discussions.microsoft.comwrote:
My understanding is that for the same socket, assuming send and receive
run
at two different threads, I have to use BeginReceive to avoid the
blocking on
send part.
How can you affect how data is sent by using BeginReceive?
However, I can jsut use Send without worrying about any threading
issue in case send and beginreceive happens at the same time on the
socket?
Am I correct on this?
If you are asking whether you can mix the use of the asynchronous receive
with a synchronous send, yes my recollection is that you can.

Pete
Jun 27 '08 #2
Thanks. I Used middleware too much and forgot some basics on socket. So if I
mix synchronous receive and send, but put each on different thread, will
send or receive affect other anyhow? I see some strange socket buffer errors
in application and trying to dig into it.

Chris

"Peter Duniho" wrote:
On Thu, 19 Jun 2008 12:27:02 -0700, chrisben
<ch******@discussions.microsoft.comwrote:
My understanding is that for the same socket, assuming send and receive
run
at two different threads, I have to use BeginReceive to avoid the
blocking on
send part.

How can you affect how data is sent by using BeginReceive?
However, I can jsut use Send without worrying about any threading
issue in case send and beginreceive happens at the same time on the
socket?
Am I correct on this?

If you are asking whether you can mix the use of the asynchronous receive
with a synchronous send, yes my recollection is that you can.

Pete
Jun 27 '08 #3
On Fri, 20 Jun 2008 06:16:01 -0700, chrisben
<ch******@discussions.microsoft.comwrote:
Thanks. I Used middleware too much and forgot some basics on socket. So
if I
mix synchronous receive and send, but put each on different thread, will
send or receive affect other anyhow?
No, that's definitely fine. The socket can handle send and receive from
different threads simultaneously.
I see some strange socket buffer errors
in application and trying to dig into it.
Well, I don't think that the errors are being caused by some specific
combination of the send/receive methods of the Socket class. :)

Pete
Jun 27 '08 #4
thanks for the help. seems i still have more homework to do :-(

"Peter Duniho" wrote:
On Fri, 20 Jun 2008 06:16:01 -0700, chrisben
<ch******@discussions.microsoft.comwrote:
Thanks. I Used middleware too much and forgot some basics on socket. So
if I
mix synchronous receive and send, but put each on different thread, will
send or receive affect other anyhow?

No, that's definitely fine. The socket can handle send and receive from
different threads simultaneously.
I see some strange socket buffer errors
in application and trying to dig into it.

Well, I don't think that the errors are being caused by some specific
combination of the send/receive methods of the Socket class. :)

Pete
Jun 27 '08 #5

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

Similar topics

0
by: James Yang | last post by:
Hi, I am using Sockets to connect to a remote computer and send data using Socket.Send() and receive using Socket.Receive() (block mode) . for somereason tho, when the client disconnects the...
3
by: Robert A. van Ginkel | last post by:
Hello Fellow Developer, I use the System.Net.Sockets to send/receive data (no tcpclient/tcplistener), I made a receivethread in my wrapper, the receivethread loops/sleeps while waiting for data...
0
by: SK | last post by:
Hi, I am trying to send/receive data from a socket. The call to receive does not block . If I use sleep between send and receive things are ok. Here is the code - Socket m_socClient;...
6
by: roger beniot | last post by:
I have a program that launches multiple threads with a ThreadStart method like the following (using System.Net.Sockets.Socket for UDP packet transfers to a server): ThreadStart pseudo code: ...
5
by: Terry | last post by:
It's my understanding of UDP sockets that if there is a thread blocked on a "recvFrom()" call and other thread sends a UDP packet to some address, that if the machine on the other end isn't up,...
5
by: mscirri | last post by:
The code below is what I am using to asynchronously get data from a PocketPC device. The data comes in fine in blocks of 1024 bytes but even when I send no data from the PocketPC constant blocks of...
3
by: Ricardo Quintanilla | last post by:
i had a problem whom i do not know how to explain. i was using a TcpClient (System.Net.Sockets.TcpClient) object to send and receive data to an AS400 socket. Two months ago it started to work...
4
by: Ryan Liu | last post by:
TcpClient has a method called GetworkStream GetStream(); So in other words, there is only one stream associate with it for input and output, right? So while it is receiving, it can not send, and...
1
by: Ryan Liu | last post by:
Hi, As I remember theare are In and Out stream associate with a socket. TcpClient seems there in only one NetworkStream to do both read and write. Then will it be a conflicit if both side try...
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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,...

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.