HighTechTalks DotNet Forums  

Question About Sockets reguarding Performance.

Dotnet Framework (Performance) microsoft.public.dotnet.framework.performance


Discuss Question About Sockets reguarding Performance. in the Dotnet Framework (Performance) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Gotisch
 
Posts: n/a

Default Question About Sockets reguarding Performance. - 05-05-2007 , 10:16 PM






I'm Writing an application that recieves data always of the Same
structure:

<packetsize(2bytes)><code(4bytes)><codespecificdat a(packetsizebytes)>

So i though the smartest way to read this data would be to first read
6 bytes for size of the packet and its code, and then another size
bytes. so that afterwards i have exactly 1 packet in the buffer.
----
socket.BeginRead(mybuffer,0,6,....)
(in call back making sure i recieved 6 bytes, or read again until i
have the 6)
get the size of the packet out of the recieved bytes and get the rest
socket.beginread(mybuffer,6,BitConverter.ToUint16( mybuffer,0),....)
in the callback make sure i recieved (inall) packetsize+6 bytes.

I can then Enqueue the Whole connection in the MainEventLoop Where the
packet is processed and another PacketGettingProzess is started.

But im getting the feeling that this is not the right way to go
performance wise.

Is there any information on what is better? small BeginReads or big
BeginReads?
At the moment my application does use around 30% cpu the
testClient(which works heavlily with threads also around 30%) and the
other 40% are used by the System process. But i guess the test arent
really conclusive since im probably putting more strain on the system
by having created 1000 sockets.
The Memory profile of both applications looks ok. but that isnt
surprising since they dont actually do something.

I will attach links to both sources,

i would love to hear some comments on what is better performance wise.
( in code i tested both (handling the packet in the callback, and
handling it in a main event loop)

(source is a bit messy sorry about that :/)
TestClient To test the server: http://paste.prco23.org/5756
ClientConnection Class: http://paste.prco23.org/5754
ServerApplication: http://paste.prco23.org/5755

Thanks,

Gotisch


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.