(X) Hide this
    • Login
    • Join
      • Generate New Image
        By clicking 'Register' you accept the terms of use .
        Login with Facebook

Forums

Search in:

Go

Live Video Streaming Issue

  • ritapsingh
    ritapsingh
    0 points
    0 posts
    Jun 16, 2011, 10:32 AM
        Report Abuse
    Hi, I am trying to develop a silverlight application that opens up multiple TCP sockets and transfers JPEG images from Camera to some other silverlight client. The issue is that  the receiving silverlight application receives junk data from the TCP sockets. I will appreciate if you let me know how to overcome this issue. I look forward to your reply. Thank you.
    Reply

All Posts


  • Bobi Rakova
    9 points
    4 posts
    Jun 16, 2011, 02:47 PM
            Report Abuse

    Hi,

    I have some experience in using TCP sockets in Silverlight.  First you have to create a DnsEndPoint and the Socket. Then you connect and start receiving data.
    For example:

    DnsEndPoint endPoint = new DnsEndPoint( Application.Current.Host.Source.DnsSafeHost, 4531 );
    Socket socket = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp );
     
    SocketAsyncEventArgs args = new SocketAsyncEventArgs();
    args.UserToken = socket;
    args.RemoteEndPoint = endPoint;
    args.Completed +=
    new EventHandler<SocketAsyncEventArgs>( OnSocketConnected );

    socket.ConnectAsync( args );

    In OnSocketConnected I receive a SocketAsyncEventArgs and attach to the Completed event.

    byte[] response = new byte[bufferSize];
    e.SetBuffer( response, 0, response.Length );
    e.Completed -= new EventHandler<SocketAsyncEventArgs>( OnSocketConnected );
    e.Completed += new EventHandler<SocketAsyncEventArgs>( OnSocketReceive );
     
    Socket socket = ( Socket )e.UserToken;
    socket.ReceiveAsync( e );

    Well now in OnSocketReceive I also receive the SocketAsyncEventArgs parameter. And I also did have some problems when reading but I found out that the SocketAsyncEventArgs e parameter has a property called BytesTransffered. When reading the received data from e.Buffer[] you should read from 0 to e.BytesTransffered but not the entire array.

    I'm not sure if this is your case, maybe you could give some more information.
    Hope this helps.

    Reply
Page  
  • 1

To reply to this thread you must Log In to your account


Thread


Tags: 
  • Asked
    64 days ago
  • Viewed
    133
  • Last Activity
    64 days ago

Related Threads


Shortcuts