Jump to content
  • Advertisement
Sign in to follow this  
Stukey

[.net] Asynchronous Socket Visual Basic .Net

This topic is 4830 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

For the asynchronous socket methods in visual basic .net, what does the size parameter pertain to? For example Socket.beginreceive(data,0,5,new asynccallback(addressof Foo),0) Does this mean Foo will be called when I receive 5 bytes, that Foo will be called when I receive anywhere up to 5 bytes, and if I receive more than 5, are the others loaded into data or lost or do they wait for me to call beginreceive again? I've read that the length parameter sets the maximum length received, but I want these more specific answers because that really doesn't say much.

Share this post


Link to post
Share on other sites
Advertisement
From my understanding it will receive the first 5 bytes and put it in the data variable. A common way of doing this is to limit your packet size. Example:

Dim Data As Byte(1024) ' I'm a C++ and C# programmer so I'm not to sure on the syntax. In C# it would be:

byte[] Data = new byte[1024];

So if I have Socket.BeginReceive(Data, 0, Data.Length, new asynccallback(addressof Foo), 0)

This will only receive a maximum of 1024 bytes. I hope that helps.

Share this post


Link to post
Share on other sites
But if it gets less data than that will it receive the smaller ammount and expect you to check the size and call beginreceive again?

Share this post


Link to post
Share on other sites
Quote:
Original post by Kryptus
Dim Data As Byte(1024) ' I'm a C++ and C# programmer so I'm not to sure on the syntax.
To clarify, that would contain 1025 bytes. You specify the upper bound on the array, so for a 1024 byte array you'd say Dim Data As Bytes(1023). Stupid, yes.

Share this post


Link to post
Share on other sites
Quote:
Original post by benryves
Quote:
Original post by Kryptus
Dim Data As Byte(1024) ' I'm a C++ and C# programmer so I'm not to sure on the syntax.
To clarify, that would contain 1025 bytes. You specify the upper bound on the array, so for a 1024 byte array you'd say Dim Data As Bytes(1023). Stupid, yes.


Haha, that's makes no sense at all! Why did they bother making array's zero based in VB.NET if that's the case. Microsoft can be silly at times :) I can see a lot of wasted/lost single bytes in VB.NET due to people thinking the array is one based.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!