I have a tcp socket on which I receive video stream. I want to receive data as packet by packet from socket so that I could remove the packet header and keep the only stream data. How can I do this??
any help will be appreciated.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t.
TCPdoesn’t work with packets / messages etc.TCPworks with bytes. You get a stream of bytes. The problem is that there’s no guarantee reagarding the number of bytes you’ll get each time you read from a socket. The usual way to handle this:Your message could be:
What you’ll then have to do is read 4 bytes and then read as much as those 4 bytes tell you. Then you’ll be able to strip the header and get the data.