|
Thanks Simon
|
|
|
|
|
Hello,
Are there side effects of setting Socket.ReceiveBufferSize to a large value (e.g. 50 MB)?
I am writing an application to receive and process a large amount of data. Instead of writing code to read data asynchronously, I was thinking of setting Socket.ReceiveBufferSize to a large number. I am not worried about consuming system resources since the program will run on a dedicated machine. However, I am not sure whether this might have a negative effect over performance, or any other side effects that I should take care of.
FWIW, my application simply uses StreamReader.ReadLine() over the socket's network stream.
Thanks a lot
|
|
|
|
|
What do you hope to gain by setting the receive buffer size that large?
Even if the system lets you do it, it will most likely hurt performance.
Why not try it and see what happens?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
By setting the receive buffer so large, I am hoping to avoid having to read data in a thread and process it in another one. At certain (and few) instances of time, I will be receiving 3X data, where X is the amount of data I can process per second. However, right following that, there will be 0.1X data for some time. So, instead of having to synchronize reader and processor threads, I was hoping the system buffer could just hold the additional data for me.
Meanwhile, I don't think I can test performance right now, because there are many other factors that I might not be able to control. So, why do you think it would hurt performance?
Thanks for your help.
|
|
|
|
|
AFAIK, Windows Sockets will let you set it to a max size of 1MB.
The receive buffer isn't meant to be a data store.
For best TCP/IP performance, your user-mode code should remove ("receive")
data from the socket ASAP. i.e. Send buffer should be full, receive buffer should
be empty.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hello,
Do someone know an algorithm for generating a smard card numbers composed from 14 numbers
best regards
dghdfghdfghdfghdgh
|
|
|
|
|
I have a TcpClient connection that connects to a local java process. When I close the form, I call dispose on my tcp client handler and kill the java process. However, this is causing the below error:
11:22:01 TcpClientHandler.Read; IOException: System.IO.IOException: Unable to read data from the transport connection: A blocking operation was interrupted by a call to WSACancelBlockingCall. ---> System.Net.Sockets.SocketException: A blocking operation was interrupted by a call to WSACancelBlockingCall
>>>> at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
>>>> at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
>>>> --- End of inner exception stack trace ---
>>>> at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
>>>> at System.IO.StreamReader.ReadBuffer()
>>>> at System.IO.StreamReader.ReadLine()
I am a bit confused as to why this error is being thrown, since when I close the form, the "Reading..." trace is never printed out.
public void Read()
{
Trace.WriteLine("##debug: Reading...", "INFORMATION");
try
{
do
{
_alertMessage = _reader.ReadLine();
if (!string.IsNullOrEmpty(_alertMessage))
{
if (MessageReadEvent != null)
MessageReadEvent(this, _alertMessage);
}
}
while (!string.IsNullOrEmpty(_alertMessage));
}
catch (IOException io)
{
Trace.WriteLine(MethodBase.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name +
"; IOException: " + io.ToString(), "ERROR");
}
}
When I dispose of the tcp client handler I dispose of the reader, and then call tcpClient.Close();
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Gareth H wrote: and then call tcpClient.Close();
No way to say this doesn't get people upset but, developing quality software can ONLY be accomplished by reading the documentation, period.
link[^]
When you are finished sending and receiving data, use the Shutdown method to disable the Socket. After calling Shutdown, call the Close method to release all resources associated with the Socket.
Gareth H wrote: I am a bit confused as to why this error is being thrown, since when I close the form, the "Reading..." trace is never printed out.
I can't explain how your code works. A wild guess is that it did print out long before you closed anything and you just are not seeing it because you are mistakenly expecting to see it print out when you close the form. That said, an exception will be thrown from a blocking read when the read is canceled. That behavior is by design.
led mike
|
|
|
|
|
I added the Shutdown call, but that didn't solve the problem. It seems that the exception is thrown the same number of times a message is sent to the java process. So, if I send 5 messages, 5 exceptions are thrown when the form is closed.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Gareth H wrote: I added the Shutdown call, but that didn't solve the problem.
Did you read my post?
led mike wrote: That said, an exception will be thrown from a blocking read when the read is canceled. That behavior is by design.
Gareth H wrote: It seems that the exception is thrown the same number of times a message is sent to the java process.
Without being able to reproduce the behavior themselves it is unlikely anyone will be able to help you. I have done socket development since 1994 and I have never seen anything such as you describe. My first guess is that the behavior is introduced by your code, not by the TCP stack or the any of the other libraries you are using.
Some of what you previously said indicates you are using threads. It is very likely you are creating a new reading thread for each message sent to the Java process since that would explain the behavior.
led mike
|
|
|
|
|
I solved the problem. Changed my Read() method to create a StreamReader in a using block.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
I need to capture the SessionEnding event in my C# app, this worked fine by adding a handler to the SystemEvents.SessionEnding event when I had message loop on my main thread. Unfortunately that is now not the case, I no longer have a message loop and now I don't get the notification.
I have tried creating a message-only window to capture the WM_ENDSESSION/WM_QUERYENDSESSION messages but these are only sent to top-level windows and not message-only windows. So I tried using SetWindowsHookEx to hook WH_CALLWNDPROC which still does not send the WM_ENDSESSION message, then I tried SetConsoleCtrlHandler which also doesn't seem to work.
Does anyone have any ideas on how I can trap this message without a main form?
Thanks.
|
|
|
|
|
Replaces "[fieldname]" in the HTML template document with data from the corresponding column of the SQLite table
|
|
|
|
|
What you are saying is not a question. I don't understand what you are trying to do.
Simon
|
|
|
|
|
Don't care.
He's just getting on everyone's nerves, posting the same crap again and again.
He's trying to find some idiot who will do his work.
Regards
Thomas
www.thomas-weller.de
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Programmer - an organism that turns coffee into software.
|
|
|
|
|
Use VS 2005.NET
Create Windows Form Application
|
|
|
|
|
The more times you post the same post the less chance you have to get an answer especially when what you are posting is homework.
|
|
|
|
|
Uhhh What do you really mean ?
Explain your problem
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Stop cross posting your homework everywhere.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
|
|
1) Use a descriptive title
2) Ask a question.
edit: 3) Dont repost the same rubbish as thread below
|
|
|
|
|
I need to know what is the major difference between "Infragestic 2007 volume 2" and "Infragestic 2008 volume 1" if anyone has the documentation pls send it to my mail ID : vinayskvs@rediffmail.com
or send me if any related links that can help me to know the difference in there features pls let me know...
thanks in advance.
|
|
|
|
|
The best place to find out would be on the infragistics[^] web site.
If they don't have the info on the site, email support, or try asking in their forums.
Simon
|
|
|
|
|
thanks stevens, i ll try to ask in their
Simon Stevens wrote: forums
only..
|
|
|
|