I am working with a TCP client to learn how to use the TCPSocket function in VS2010 C#. I can call the read() function to read the data. That part all works. What I am not understanding is how to set the client up to listen to the stream and post the incoming data to a text box without calling the function manually or using a timer. I would like to have this handled with an event handler, but at this point I have just completely confused myself and now I need some guidance.
I am using a client sample I found on MSDN to help me understand how the function works to do a basic read.
Subscribes to the TextChanged event raised by the LineEdit. This method will override any prior subscription, including those assigned to on event handlers. This has the advantage that it does a straight connection and returns a handle that is easy to unsubscribe from. Universal SubscriptionOur Best Value – includes over 500 UI Controls, our award-winning reporting platform, DevExpress Dashboard, the eXpressApp Framework, CodeRush for Visual Studio and more. DXperience SubscriptionSave Hundreds – includes DevExpress UI Controls for WinForms, ASP.NET, MVC, WPF, our award-winning reporting platform and CodeRush for Visual Studio. Of note for Messenger plus! Users: You have to change the lock shortcut, even if it is disabled it interferes with Visual Studio. > Preferences & Options > Features > Messenger lock, and, Plus! > Passwords > Unlock Messenger.
On an other stackoverflow post I found Matt Davis provided an example of using a public event
However when I tried it, the 'DataRecivedEventArgs' is not a recognized function of visual studio.
Can someone help explain to me how to use TCPclient to consistently listen for data and call a function when some data is received?
1 Answer
For a given TCP connection, received data is buffered in the Kernel up to its buffer size limit (which is opaque to the application).
When an application wants to receive data it has to explicitly tell the Kernel how much data needs to be copied to the application buffer, because the buffer size is not infinite and that Kernel may be storing incoming payloads faster than your application could handle (don't forget your application is regularly preempted).
The only way for your application to receive data from a TCP socket is through recv()
, recvfrom()
, recvmsg()
system calls.
In your case, in User Space, all you can do is call the functions that correspond to those syscalls so you can receive data. Delivery is on-demand by design. In addition, the application won't know if data has arrived until it calls recv()
, recvfrom()
, recvmsg()
, select()
, poll()
or epoll()
.
Note: I am not a C# person. I know C and Kernel internals and that's pretty much it. I just wanted to point out the concept behind socket communcation.
Not the answer you're looking for? Browse other questions tagged c#socketstcpevent-handlingtelnet or ask your own question.
-->Note
No new features or functionality are being added to Media Services v2.
Check out the latest version, Media Services v3. Also, see migration guidance from v2 to v3
Azure Media Services support offline download/playback with DRM protection. This article covers offline support of Azure Media Services for Windows 10/PlayReady clients. You can read about the offline mode support for iOS/FairPlay and Android/Widevine devices in the following articles:
Overview
This section gives some background on offline mode playback, especially why:
- In some countries/regions, Internet availability and/or bandwidth is still limited. Users may choose to download first to be able to watch content in high enough resolution for satisfactory viewing experience. In this case, more often, the issue is not network availability, rather it is limited network bandwidth. OTT/OVP providers are asking for offline mode support.
- As disclosed at Netflix 2016 Q3 shareholder conference, downloading content is a “oft-requested feature”, and “we are open to it” said by Reed Hastings, Netflix CEO.
- Some content providers may disallow DRM license delivery beyond a country/region's border. If a user needs to travel abroad and still wants to watch content, offline download is needed.
The challenge we face in implementing offline mode is the following:
- MP4 is supported by many players, encoder tools, but there is no binding between MP4 container and DRM;
- In the long term, CFF with CENC is the way to go. However, today, the tools/player support ecosystem is not there yet. We need a solution, today.
The idea is: smooth streaming (PIFF) file format with H264/AAC has a binding with PlayReady (AES-128 CTR). Individual smooth streaming .ismv file (assuming audio is muxed in video) is itself a fMP4 and can be used for playback. If a smooth streaming content goes through PlayReady encryption, each .ismv file becomes a PlayReady protected fragmented MP4. We can choose an .ismv file with the preferred bitrate and rename it as .mp4 for download.
There are two options for hosting the PlayReady protected MP4 for progressive download:
- One can put this MP4 in the same container/media service asset and leverage Azure Media Services streaming endpoint for progressive download;
- One can use SAS locator for progressive download directly from Azure Storage, bypassing Azure Media Services.
You can use two types of PlayReady license delivery:
- PlayReady license delivery service in Azure Media Services;
- PlayReady license servers hosted anywhere.
Below are two sets of test assets, the first one using PlayReady license delivery in AMS while the second one using my PlayReady license server hosted on an Azure VM:
Asset #1:
- Progressive download URL: https://willzhanmswest.streaming.mediaservices.windows.net/8d078cf8-d621-406c-84ca-88e6b9454acc/20150807-bridges-2500_H264_1644kbps_AAC_und_ch2_256kbps.mp4
- PlayReady LA_URL (AMS): https://willzhanmswest.keydelivery.mediaservices.windows.net/PlayReady/
Asset #2:
- Progressive download URL: https://willzhanmswest.streaming.mediaservices.windows.net/7c085a59-ae9a-411e-842c-ef10f96c3f89/20150807-bridges-2500_H264_1644kbps_AAC_und_ch2_256kbps.mp4
- PlayReady LA_URL (on-prem): https://willzhan12.cloudapp.net/playready/rightsmanager.asmx
For playback testing, I used a Universal Windows Application on Windows 10. In Windows 10 Universal samples, there is a basic player sample called Adaptive Streaming Sample. All we have to do is to add the code for us to pick downloaded video and use it as the source, instead of adaptive streaming source. The changes are in button click event handler:
Since the video is under PlayReady protection, the screenshot will not be able to include the video.
In summary, we have achieved offline mode on Azure Media Services:
Outlook Mac Subscribe To Calendar
- Content transcoding and PlayReady encryption can be done in Azure Media Services or other tools;
- Content can be hosted in Azure Media Services or Azure Storage for progressive download;
- PlayReady license delivery can be from Azure Media Services or elsewhere;
- The prepared smooth streaming content can still be used for online streaming via DASH or smooth with PlayReady as the DRM.