osamaT

Hi,

In my application im sending video from a client to a server which redistribute the video to all other clients..

this is easy if video is sent from one client.. but what i need to is to send the video from more than one client .. now the problem is:

on the server side i can determine where the data is coming from using the objectstate parameter, and since data comes from different sockets .. its easy to keep track of who sent it.

but on the client side.. its connected using only one socket.. and the server send the data (video in this case) to the client using this socket information.. so i cant use the objectstate becuase the data is always coming from the same source or socket..

how can i determine (on the client side ) who the data received belongs to!

i will try to make it simple because i know my English is not perfect i may mislead ...


User1 sends video to Server
Server Saves the User1 ID on the object state
Server sends the video to User2
User2 receives the video and display it.

so far so good.. but if User2 wants to send video as well..

User3 doesn't know to whom the video received belongs to..

Please advise.. and if u don't understand any part of my problem please let me know.. i need your help ..

Thank you



Re: .NET Framework Networking and Communication Socket identification problem

RizwanSharp

Here:

Server Accepts Client 1 and assigns it ID1

Server Accepts another Client 2 and assigns in ID2

Server Accepts another Client 3 and assings in ID3

Now Server Sends Video Received from Client1 and Client2 to Client 3.

How will Client3 know that what video is of Client1 and what is of Client2

The simplest answer is that The Server should append an header with each packet and then send to the client. a header may include the information about the client e.g Client ID.....

You packet will be something like this:

{ClientID}{VideoData}

{ID2}(5794328598420958230984098320840328409823984032.........}

CientID = ID2;

VideoData = 5794328598420958230984098320840328409823984032.........;

Upon Receiving Remove the Client ID part from the packet and play the Video Data part.

I hope this will help.

Best Regards,

Rizwan aka RizwanSharp






Re: .NET Framework Networking and Communication Socket identification problem

osamaT

 RizwanSharp wrote:

Here:

.

.

.

.


You packet will be something like this:

{ClientID}{VideoData}

{ID2}(5794328598420958230984098320840328409823984032.........}

CientID = ID2;

VideoData = 5794328598420958230984098320840328409823984032.........;

Upon Receiving Remove the Client ID part from the packet and play the Video Data part.



That is true.. but the problem is when the server send the data to the clients.. it doesn't necessarily send it all at once .. lets say that the data length is 2500 bytes.. the server may send them like this:

VideoData = {5794328598420958230980000004098320840328409823984032}

Server will send
{ID2}{5794328598420958230984098000}

and then send the rest of the data .. so i will lose the {ID2} part..

I read somewhere that if i use the sockettype RAW i might be able to modify the packet header.. but i didn't really understand how.. if you have any ideas about this or any other solution .. please let me know.





Re: .NET Framework Networking and Communication Socket identification problem

RizwanSharp

osamaT wrote:
RizwanSharp wrote:

Here:

.

.

.

.


You packet will be something like this:

{ClientID}{VideoData}

{ID2}(5794328598420958230984098320840328409823984032.........}

CientID = ID2;

VideoData = 5794328598420958230984098320840328409823984032.........;

Upon Receiving Remove the Client ID part from the packet and play the Video Data part.



That is true.. but the problem is when the server send the data to the clients.. it doesn't necessarily send it all at once .. lets say that the data length is 2500 bytes.. the server may send them like this:

VideoData = {5794328598420958230980000004098320840328409823984032}

Server will send
{ID2}{5794328598420958230984098000}

and then send the rest of the data .. so i will lose the {ID2} part..

I read somewhere that if i use the sockettype RAW i might be able to modify the packet header.. but i didn't really understand how.. if you have any ideas about this or any other solution .. please let me know.

It doesnot matter You can send ID with each message. Can you tell me the scenerio of your applicaiton and data flow may be I guide you better.

Best Regards,

Rizwan aka RizwanSharp






Re: .NET Framework Networking and Communication Socket identification problem

osamaT

Hi..

In send the ID with each message, do you mean that it will be sent with the packet header, or with the array of bytes i am sending and if its something like the tcpip header or the packet header,, how can i modify it and put my ID in it

Thank you.

Osama Tamimi





Re: .NET Framework Networking and Communication Socket identification problem

osamaT

Ok..

First of all i take a picture from the camera..

Then i convert it into an array of bytes in which i add at the start the position of the user in the list located at the server, then i add the length of the picture..

Then i use a timer to send this picture in chunks .. 1000 bytes at a time .. so it doesn't affect the audio performance on some low speed connections.. specially if its sending more than 5 frames per second..

now.. at the server side.. i have the user position stored in a class i created .. which i pass in the Object state parameter,,  this way i can keep track of each packet.. who sent it and what is his index in the list... and then i send it to all other clients in the list.. i do not modify it at all on the server side.. it just forwards the packet..

on the receiving end of the client..

when the data arrives i check the first byte (in which i stored the position of the user) and using this identifier i store the data on different List<byte>s .. then a timer check this data.. and get the first 4 bytes of it and convert them into an int32 .. this should be the length of the picture to be received.. and a while loop.. as long as the data received is not more than the length of the pic.. keep waiting for more data.. else.. display the picture and wait for more to come.







Re: .NET Framework Networking and Communication Socket identification problem

RizwanSharp

Exactly, Its quite Well.

I hope you are not facing any problem now, Right

Best Regards,

Rizwan aka RizwanSharp