PDA

Click to See Complete Forum and Search --> : udp protocol...


choochoo
Jun 3rd, 2001, 06:09 PM
Hey everyone, im having trouble with my winsock control.
I'm pretty familiar using winsock, as i have written a few chats, and other things with it that werent really useful.
The problem is, im trying to work with the UDP protocol this time, instead of the TCP Protocol. I've neve worked with the UDP before, and therefore im having a hard time trying to send data back and forth and debugging my program to see whats wrong. I kept a timer on the form that lets me know what state winsock is in, but it either only returns 0(Closed) or 1(Open). Im not really even sure how to make a connection with UDP, so any examples or help you can give me is appreciated. Thanks.

choochoo
Jun 4th, 2001, 01:50 PM
Thanks for your post Josh...

but, whats the point of having a UDP protocol then?

JoshT
Jun 4th, 2001, 02:40 PM
Stuff that doesn't need a connection. A good example would be streaming audio. The audio gets sent as packets, but if you don't recieve a packet of the audio, there's no point in re-request it as you've already heard the skip and the song kept playing. Windows networking uses this as well - when a computer starts it sends a "Hey, computer COMPNAME is on the network" message to the whole local network. It doesn't care who gets it or not and doesn't need a reply back.

choochoo
Jun 5th, 2001, 04:27 PM
Josh...that was kinda what i wanted to...only, not sending audio.
I heard that UDP was for sending packets...thats what i wanted to do, i wanted to make a basic file-sharing program...but theres something wrong with it i think, because it wont send the data...unless im doing something wrong...if you want me to upload the form and take a look at it for yourself, let me know...thanks again.

CiberTHuG
Jun 6th, 2001, 08:24 AM
Josh is right, UDP is connectionless, and it has a great use in streaming media and system announcements. That is actually when I run into it the most is when a program needs to wideband data. It will broadcast it across the network on half a dozen UDP ports. It doesn't care if anyone gets it, and it doesn't care how many people get it.

There is a systems monitoring tool, Candle Command Center, that uses agents on remote host to monitor some application or system function. The hub and the agents communicate via UDP, this way the hub doesn't have to explicitly send a message to each agent in the field, it can send the message once and all the agents listening can hear it. The agents likewise can broadcast so the hub and its back up can both hear it. Besides, if the agent is talking, there is a problem, and the problem may be network related, so there is no need to spend time trying to set up a connection if the network might be down. If it goes through, great, if not, well the agent will miss the next "I'm alive" poll from the hub and will be reported as offline to the sys admins who are monitoring.

Anyway, I wouldn't use UDP for file sharing unless you didn't want to worry about security and you had several servers that were trying to keep in sync.

choochoo
Jun 6th, 2001, 02:53 PM
CiberTHuG, are you suggesting I use TCP then to send the file?
Im pretty sure the code I wrote is right, and if it isnt I most likely could fix it since I've had experience using TCP connections before...

Thanks for replying, once again :)

PS: Josh, whats your suggestion?
PSS: Anyone else have a suggestion? :)

JoshT
Jun 7th, 2001, 06:59 AM
I agree with CiberTHuG - use TCP.

Thomas Vanhanie
Jun 7th, 2001, 07:48 AM
I to agree, use TCP.
I'm making an ActiveX so that I easily can send and recive files over the net.
And you have experience of winsock so you know how to do.

The only thing is that you must divide up the files into packets and then send them.
Do you know how many bytes winsock can send in one package?
I guess I will have to test it out...

choochoo
Jun 7th, 2001, 03:39 PM
thanks once again for responding :)

thomas...im pretty sure winsock can send as many bytes as needed in one package, since i use a file sharing program that was made in vb---with a cable modem, ive seen speeds of 260 kb p/sec and greater .... i guess that answers your question :)

Thomas Vanhanie
Jun 8th, 2001, 03:33 PM
I tested winsock and the largest package it can send in one turn is 8192 bytes. But when i tested sending 20000 bytes it kept on sending until it had sent all 20000 bytes, so I don't know if Microsoft has baked in a function that splits the package into right sizes or if it has been there all the time... I use the latest service pack so I don't know...

I to have got up to about 230 kb/s... But I'm testing now if I can use multiple winsocks to send same file thrue multiple ports and so on...
If you want to know something you must test it if it works ;)

choochoo
Jun 8th, 2001, 07:50 PM
Thomas, yesterday I was wondering why when I sent a 7kb file, it turned into 41 kb - ALWAYS, if it were anything under 41. I then realized that i mistaked PacketSize for BaudRate .... speaking of BaudRate, is there a way to get it? Im not sure of how you would get the baud rate of the file being sent, but I sent myself a 3meg file last night @ 2kb packet size and received it in about 10 seconds...someone wanna help me -- yet AGAIN? :)

Thomas Vanhanie
Jun 9th, 2001, 03:46 PM
I have solved the problem with a timer and a global variable...
You just need to increase the variable everytime the code sends something (increase with the sent package size) ;)

You can set the timer to 1000 (1 second) but I have set it to 3000 so that I get a more stable number...

If you set the timer to 3000 you can set a code like this to the timer... (I guess you see what happens in the code) ;)

Timercode (timer set to 3000 to get a more stable number)

lblSpeed = lngSpeed / 3
lngSpeed = 0


That's the basic thing...
Of course you set what you want as names :)
I raise an event every time the timer goes thrue the code...
This code can give you an error ("division by zero") but you know how to handle that I supose (I don't write it here) ;)
But if you want to know I can write it :)

Hope this code helps you!
And you can use something similar to the reciving part to (I use the same timercode)

choochoo
Jun 11th, 2001, 06:53 AM
Thomas, that kindof helped...I didnt understand what you meant by a division by zero error, although I saw where the error would take place....I haven't been working much on this lately, but ill get around to it in about a week or so ( hopefully :\ ) I didnt put that code in vb either so i guess that would have helped if I tried that. heh :) well, hmprgh, keep posting I guess heh

Thomas Vanhanie
Jun 11th, 2001, 01:12 PM
Well, I will keep posting :)

Division by zero will happen if the speedvariable sometimes becomes "0", because you can't divide zero by three, or visual basic can't ;)

But if you set the timer to 1000 you don't get it because you don't need to divide the speed variable with three or whatever you use...

I'm right now working on my filetransfer ActiveX...
But I'm rewriting some of the code to hopefully fix some smaller problems and get better code... ;)

Well, you can keep posting to :D
Be well! :)

choochoo
Jun 11th, 2001, 05:47 PM
Thomas, heh, I haven't had much time with programming lately, like I said in my last post, I'll be getting around to it in a week or so (yet i have enough time to write this post heh) ... I understood the division by zero before you posted that...I just meant i never saw that error before...I'll start posting on this thread again once I get back into finishing that thing...keep on posting and ill keep on checking back heh :)

tonyenkiducx
Jun 12th, 2001, 11:08 AM
Sharing files and copying them safely is a major pain, expecially with dropped packets and resuming.. The easiest(And I do stress easiest, this isnt the best way) way is to use directplay, which can automatically deal with packets and streams.. Winsock has the problem of receiving streams in pieces, then you need to do work to put them back together again, particularly on multiple connections. Directplay just does it for you, making sure nothing is lost, and that the data doesnt get mixed up..

choochoo
Jun 12th, 2001, 11:57 AM
Directplay? im guessing thats something with DirectX ... which I've never used before so i have no clue how it works :\
If you want to leave me an example, feel free to...
I'm using DX7 though, I think... heh

Thomas Vanhanie
Jun 12th, 2001, 12:31 PM
I always use Winsock and I haven't got any problems yet...
But I will see if problems occour when I have modified my code so that I can use multiple connections ;)

I have never heard of directplay, but as you said it seems to be some DirectX thing.
But I will probably stay with winsock and packages :)

Well, see ya!

choochoo
Jun 12th, 2001, 05:20 PM
I haven't had problems with winsock either Thomas...
since I'm more familiar with it, ill probably stick with it anyways.
thanx for the feedback, as usual, and keep posting heh :)

ill be getting back to programming soon, I'll let you guys know when :)

tonyenkiducx
Jun 13th, 2001, 04:09 AM
Directplay is made for what your doing, if you send a file, directplay makes sure it gets there, in one peice, in the right order, and allows you to resume it. With Winsock you need to code all that by hand... But, its your choice, directplay doesnt go cross platform, but it is compatible with directX4, so long as you use old code.

choochoo
Jun 13th, 2001, 11:18 AM
tonyenkiducx, i would appreciate an example of how to use this, since i've never worked with it before, if you have time to write one...even though i might not end up using that code.
thanks for the feedback :)

this is like the highest viewed thread ive seen on the ASP, VBScript, Internet and Network Development I've seen...good job heh :)

Thomas Vanhanie
Jun 13th, 2001, 12:48 PM
Well, I'm allmost ready with my changes in my code, and I'm connecting with multiple winsocks now :)
And it works good, but I'm only getting speeds up to 250-300 kb/s... But that's not to bad ;)

I guess it's the DoEvents command that slows it down...
But I don't use it to much but it slows things down anyway...

See ya!!

choochoo
Jun 13th, 2001, 01:20 PM
Thomas, what kind of connection are you on? heh, i think 250kbps would be good enough for me :) I was using DoEvents in my coding...But then again I havent really worked on it for a while, but im getting back to it...sooner or later...hehe :)

Thomas Vanhanie
Jun 14th, 2001, 02:03 PM
It's diffrent; sometimes just an ordinary 56 modem and sometimes T1 or something like that, can be higher...
I'm just now on a simple modem but we will soon get ADSL so the speeds will go up :)
And in my own appartment I will get around 10Mbit/s in and out, and that's pretty good speed :D

I have now got speeds around 400 kb/s, and almost 500 kb/s...
But I'm working on a better function :)

choochoo
Jun 14th, 2001, 02:56 PM
heh good job :)
i dont prefer DSL, I find it veryyyyyyyy slow.
but then again its not my choice :)

a couple more days and ill get back to programming that...
porobably on monday/tuesday

Thomas Vanhanie
Jun 15th, 2001, 12:11 PM
Well, DSL isn't the fastest but it's better than ordinary modem...
But who knows, in the future we may get faster :)
But as I said, I will get 10 Mbit in and out in my appartment in the fall... :D

And I'm working on the speed but I think I have reached my limit for now, but who knows ;)

Well, happy programming :D

choochoo
Jun 15th, 2001, 01:25 PM
yeah, anything's better than 56k.
heh, how can you get 10megs p/sec with DSL?
...weird. anwyays, happy programming to you too heh :)

monday comes in 3 days...

Thomas Vanhanie
Jun 15th, 2001, 04:00 PM
It's not DSL when i get 10 Mbit...
I have two places where I am.
Here with my parents and my appartment where my school is...
So it's here at my parents house the DSL will be installed and at my appartment the 10Mbit cable :)

Yeah, monday is only three days away, soon two ;)
I will see what improvments I can do on my code :)

See ya!

csammis
Jun 16th, 2001, 01:23 AM
Just a comment regarding DirectPlay:

It has it's upsides and downsides, but I would recommend sticking with Winsock at this stage, for a couple reasons:

1) As someone previously mentioned, it isn't cross-platform, and that's a big deal if you send to a major web server/computer on the internet (odds are it's a *nix varient)
2) You do know Winsock, and that's a great thing...but one can always learn more :) Having DirectPlay encapsulate functions is a great thing, but not only will you learn more but you'll have more control over what you're doing
3) If you distribute your apps, you're asking every user to have at least DirectX-whatever on their computer, and it's just one more thing for your user that they don't want to have to do

Just my two (well, three!) cents :)

choochoo
Jun 16th, 2001, 08:26 AM
thanks for the feedback csammis....
I plan to eventually learn all this stuff heh
but for now, im stuck on stupid problems.

i know this doesnt have to do with networking development & so forth, but im having trouble saving a treeview...

take a look at my post:

http://161.58.186.97/showthread.php?s=&threadid=83371

csammis
Jun 16th, 2001, 12:18 PM
Looking right now...I think I see the error...