• Advertisement
Sign in to follow this  

Sending large objects with .net sockets

This topic is 3626 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

I'm in visual basic .net using async sockets. When a level is first loaded by a player if the hashes don't match or the player doesn't have a copy of the level I want to send it, the problem is there is a possibility that the level will serialize to more bytes than can be written as the position parameter of beginreceive (which is type integer). Basically I want to know if there is an easier way to transmit larger objects over sockets. The only option I see now is to use an array of buffers but I don't really want to do that if it's avoidable.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Stukey
(which is type integer).


Largest number an integer (32-bit) can represent is usually 4 billion. Or, 4 gigabytes of data.

Quote:
Basically I want to know if there is an easier way to transmit larger objects over sockets. The only option I see now is to use an array of buffers but I don't really want to do that if it's avoidable.


How large? Larger than primitive types? Larger than MTU (~530 bytes), larger than max MTU (~1400 bytes), larger than frame (64kb)....

There's several solutions (in rough increasing order of complexity):
- Use .Net marshalling (does everything automatically)
- Use TCP, you can send data of arbitrary length
- Serialize all data one way or another, then send it in small, indexed packets
- Write your own protocol

Share this post


Link to post
Share on other sites
Thanks, yeah, pretty sure this was an easy fix, problem was a math overflow cause I was trying to use int64, not an actual size problem.

Share this post


Link to post
Share on other sites
If any item you are trying to transmit over the Internet is larger than about 1MB, you've got major problems imo. Players aren't going to want to sit around for 10 minutes while the game downloads stuff. And a megabyte you can just throw at the socket's stream.

Share this post


Link to post
Share on other sites
nah, levels are only like 69k atm and I haven't even put any effort into compressing tilesets or anything yet, plus they are only downloaded when it's newer than the version you have, I personally like the idea of waiting inbetween levels more than doing a huge download before the game loads, plus it means I can update content without shutting down the server and releasing a patch. I'm stealing the idea from some other game I used to do admin on cause I thought it was really nice.

Share this post


Link to post
Share on other sites
Quote:
Original post by Stukey

I'm stealing the idea from some other game I used to do admin on cause I thought it was really nice.


Guild Wars uses this concept as well, but social side has led this feature to become being somewhat undesired.

The problem occurs when you have 7 people with fully downloaded content + a first timer. First timer may be on dial-up and will take 10 minutes to load. What will the rest do? Wait? Be locked? Go on?

What about PvP? Where your side has half of the team loading for 3 minutes?

Background downloading makes reasonable sense, so does incremental patching. But using lazy downloads (only what's needed, when it's needed) goes against the grain of MMOs, where you're not really expecting for people to visit only a tiny fraction of all content, but are trying to get them to visit everything.

As such, lazy downloads turn out to be sub-optimal algorithm.

Complete on-demand download however is simply unsuitable for game-like applications. SecondLife and other virtual worlds are different.

Share this post


Link to post
Share on other sites
Quote:
levels are only like 69k atm

Then there is no problem, just throw it at the socket. You need 3 bytes to define the length (64k is the most that will fit in ushort = 2 bytes) but as you say the parameter in question is an int (4b) that is fine.

Share this post


Link to post
Share on other sites
Yeah, it's working now, and I think progressive loading will be ok cause I'm not going for mmo in the traditional sense really, and it won't be instance based so people might get held back somewhat but I'm not really planning a required party structure yet, that and mostly I'm not worrying about specifics at all cause I still don't know if I even have the ability to finish it, I made it work offline already but the changes to add networking are so dramatic it's been pretty much ripped apart and as of now all I have is the login/initial loading mostly done.

Share this post


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

  • Advertisement