Click here to Skip to main content
15,881,281 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello ,


i am working on window project i want to put some url(http,rtmp.rhsp,mms)and whant to check if they working of not using C#
till not i am able find only for http but for RTMP, MMS, RTSP no luck .

my code


C#
string url = "www.google.com";
           try
           {
               HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
               webRequest.Method = "GET";

               string responseData = string.Empty;
               HttpWebResponse httpResponse = (HttpWebResponse)webRequest.GetResponse();

               using (StreamReader responseReader = new StreamReader(httpResponse.GetResponseStream()))
               {
                   responseData = responseReader.ReadToEnd();
               }
               MessageBox.Show("found");
           }
           catch (System.Net.WebException ex)
           {
               MessageBox.Show("not found");
           }
       }

any help will we appreciated

lakhan
Posted
Comments
Sergey Alexandrovich Kryukov 11-Nov-13 2:16am    
The problem is: the runtime type of WebRequest is defined by the URL (you should use full URL starting with the scheme).
And not many types are supported. You need to do it on lower, TCP level, for scheme other then http://, http://, ftp://, and file://...
—SA
Orcun Iyigun 11-Nov-13 2:26am    
I totally agree to your comment. On top of his code I can suggest:
- He can use FileWebRequest Class[^], and try getting a just enough of it from the stream to check if it is active or not. Moreover, TcpClient Class[^], this is also another way to see if the server is listening for the http, rtsp, and mms ports or not.
Sergey Alexandrovich Kryukov 11-Nov-13 2:40am    
TcpClient looks like quite a good idea to me, but not file. Maybe I did not get it. How can it be possible?
—SA
Orcun Iyigun 11-Nov-13 2:51am    
Opps, I wasn't clear there sorry and you are right about it. If there is a file involved, he can use it as an option to see if he can download a piece otherwise as you said it would not help him to figure it out. But TcpClient should work no matter what.
Orcun Iyigun 11-Nov-13 2:53am    
I just found that article here on CP. It may help you on RTSP: Managed Media Aggregation using Rtsp and Rtp[^]

1 solution

i way to sort out it...


now i am using Rtmpdup i run command to Download a piece of video and than if i am able to Download file so simply its mean than link is running


C#
public string RtmpURL(String Url)
       {
           var currentLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);

           // Get the path for Sox and Lame external applications used for sound processing.
           string rtmpDump = Path.Combine(currentLocation, "Tool\\Rtmpdump\\rtmpdump.exe");
           string filepath = Path.Combine(currentLocation, "Tool\\Rtmpdump\\temp.flv");
           string Result;
           //const string rtmpDump = "D://rtmpdump.exe";
           string rtmpDumpArguments = " -v -r " + Url + " -o temp.flv -B 1";
           Result = RunExternalExe(rtmpDump, rtmpDumpArguments);


           var theFile = new FileInfo(filepath+"temp.flv");
           if (theFile.Exists && Result == "yes")
           {
               File.Delete(filepath);

               return "yes";
           }
           else
           {
               return "no";
           }

C#
<pre lang="c#"><pre lang="c#">
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900