Advertisement

VB Winsock question

Started by April 27, 2002 09:56 PM
8 comments, last by FMAjmi 22 years, 9 months ago
Hi, here goes 1-What are the limitations to the Winsock control? 2-Is there a limit to the amount of data that I can send in one shot? 3-What happens if the client gets disconnected while the server is sending data to it? 4-Can I send 2 different types of data in one shot, for example can I do this: “Winsock1.SendData MyString & MyByteArray()” 5- If the connection is slow what happens to the program flow when it reaches the SendData part does it pause until all the data is sent or should I explicitly tell it to and if so how can I do it? Any help is greatly appreciated. Thanks
Only real men use C++.

CEO Plunder Studios
[email=esheppard@gmail.com]esheppard@gmail.com[/email]
Advertisement
Only real people with questions or answers post here. And no more lama ass talk if you don’t mind.

[edited by - fmajmi on April 28, 2002 3:38:41 AM]
Go here:

www.rookscape.com/vbgaming/


Look in the files section for a demoo using Winsock API to make a game. Using the API calls will be a lot nicer for you in the long run. And this demo will probably answer most of your questions.

quote:

Only real men use C++.

CEO Plunder Studios


Only real men are the CEO of a "company" that has a website hosted by tripod.

Trying is the first step towards failure.
Trying is the first step towards failure.
quote:
Original post by ragonastick
Only real men are the CEO of a "company" that has a website hosted by tripod.

Exactly.



CEO Plunder Studios
[email=esheppard@gmail.com]esheppard@gmail.com[/email]
Ellis, the point is that this thread is not about C++ vs VB, so why mention it? A language is a tool to get a job done, so if VB works then why not use it? I prefer C++ too, but it''s just a matter of preference.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
Advertisement
As for different types, try to remember that everything is just byte arrays. Strings are byte arrays, integers are byte arrays (4 bytes to an integer), floats are type arrays, etc etc.

-----------------------
"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else''s drivers, I assume it is their fault" - John Carmack
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
I'll try and answer these one by one, hopefully some of what I say will help

1 - I wouldn't say the Winsock control has any major limitations, it provides an interface to the winsock layer which is easy to use and reliable(as far as i know). I used it to make a HTTP server, IRC server, small multiplayer RPG, and didn't see any major problems with it. I think the limitations would lie in the speed with the TCP protocol, theres been TONNES of questions about which is the better protocol, TCP or UDP, speed vs reliability, etcetc.

2 - The amount of data would depend on the MTU(maximum transmission unit) of the device you're sending your data through, and also how the winsock layer decides to split your data up. If your connection is maxed out whilst downloading, and you're trying to load a webpage, the packets of data for the webpage could be crawling in at chunks of 500~ bytes.

3 - If the client gets disconnected whilst the server is sending information, then all would be well if your code has a good error handling system, the data won't get to the client(obviously), and you will recieve a Component.Closed event, and a Component.Error event, how you want to handle these is up to you.

4 - You can send whatever data you want, just as long as you know how to parse the data when the other end of the connection recieves it, either by fixed width, delimited or send the length of the data. eg..

Fixed width:            "My Name Is Dale           "            "Hello                     " 


This is clearly a waste of bandwidth, and introduces problems when you want to send data longer than the fixed width length.

Delimited:            "100¬120¬1"            "10¬14¬2" 


Assuming the data is: X position, Y Position, Player Number this could be a good way of sending the information, just as long as the data being sent can not have the delimiting character in it.

Variable length:            "3¬3¬4¬4¬All¬Your¬Base" 


Similar to delimited, the first number is the number of words, and the next 3 are the sizes of the words.

5 - If the connection is slow, the SendData will still get your data and cache it until it can be sent. You don't need to pause but designing your program to not fill up the buffer quite so quickly by checking the Component.SendComplete event is one way to go about it. But how the data is handled is completely up to the application of windows sockets.

C++ vs VB vs Delphi.. choose the right horse for the course, nuff said. and I frankly am getting seriously annoyed about the fact that every frikkin post on gamedev is now turning into a rant.. ffs people grow up. no comment on this please.. at least in a post where somebody is asking a question.

[EDIT: sorted out formatting]


[edited by - Zanthos on April 28, 2002 8:40:02 AM]
Elis, quit trolling.

This belongs in the networking forum, which is where I''m moving this.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions ]
Thanks MEN and sorry for miss placing the post.

This topic is closed to new replies.

Advertisement