How to send multi data bytes within single packet using winsock

I have a problem in my final year project.
I am doing my project as an application of the voice over IP technology.
I did the hardware part that can send and receive the sound with pc serially using the MSComm port "Microsoft communication port"  while the  vb6.0 "visual basic 6.0" will take the sound bytes from the MSComm port and send it in a form of packets using the Winsock.
But in the  VB 6.0  part i have a problem with using the Winsock since the Winsock is taking every sound byte and make it by it self as a packet which caused me an extreme malfunction and overflow in my LAN network.
So I need your help in forming the received sound bytes from the MSComm port to a packet form containing 1000 sound bytes and send it as a single packet in the Winsock.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
How big is each "sound byte"?...

What are they being stored in?  A string?  A byte array?

Make yourself an array of "sound bytes" and add each sound byte to it, keeping track of how many are in it.  When its full, send it off.  Reset your counter...

Or just concatenate them together as a long string and send that.  You need to make sure the receiver on the other end knows how to distinguish the end of one sound byte from the beginning of the next.  If they are fixed length then it is easy.   If they are variable then you need to make some kind of sound byte delimiter that marks the end of a sound byte.  This way you can seperate out the multiple sound bytes on the other end properly.  This will also let you know if you have received only a partial sound byte.
tarik_bizriAuthor Commented:
hello  Idle Mind
the sound byte is a string
and i cant control the nomber of the sound byte ;received to me from the  MSComm; that i will send thru packets so i will use variable size packets and i will put inside the packet a start byte and size of the packet and an end byte
i will use forloop inside a dowhile loop to do for  me this idea

i will try this solution and if it gona work i am gona take it
and i am very thankfull for ur help
tarik_bizriAuthor Commented:
okay mr idel mind
i did solve my problem with the udp protocol
but i need to order my packet in a certain way that i can read them in the same order
so i need to add a sequence nomber to the packets at the sending side and at the recieving side if u have any code i would be thankful
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
That's a whole different ball game...and one of the pains in using UDP!

If you were able to add start/size/end bytes into your packets I don't see why you wouldn't be able to modify it for your latest requirements...

You need to somehow store your packets as they come in some kind of rearrangeable (sp?) structure...or be able to at least store pointers to them so you can easily retrieve the next piece in the sequence.


(1) Build a Class to encapsulate your sound bytes and store them in a Linked List fashion.  When you receive a new packet, insert it into your linked list in sorted order.

(2) Use a collection object and add your packets  to it using their sequence number as the key.

(3) Use a global string that you insert the packets into using sring manipulation functions like Mid(), Left(), Right().  This could get real slow and ineffecient if your strings are large!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.