• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

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.
0
tarik_bizri
Asked:
tarik_bizri
  • 2
  • 2
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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.
0
 
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
0
 
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
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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.

Possibilities:

(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!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now