Network data is a big-endian mode, and in C # data in the small end of the structure, then read and write network data need to be converted. C # class Library IPAddress has encapsulated the conversion of the size end.The encapsulation code is as follows:[CSharp]View PlainCopy
Using System.IO;
Using System.Net;
Using System;
Namespace Framework
{
public class NetStream
{
private MemoryStream stream;
private BinaryReader reader;
more control on the code, and ensure that the program does not operate the disk frequently.
4. NetWorkStream class
NetWorkStream is a stream used to process the communication between the server and the client. It is often used in network programming. It is mainly used to process the streams obtained in classes such as Socket, TcpClient, and TcpListener.
In simple TCP synchronization mode, the Server communicates with the client:
1 1 TcpListener lis = new TcpListener (5000); // server listener
the byte stream and the string does not deviate from the encoding method. Causes a subsequent decryption operation to occur unexpectedly.Client1//Create TCP connection 2 TcpClient TCP = new TcpClient ("localhost", 11000); 3 4//Get network traffic from the TCP connection 5 NetworkStream NetStream = tcp. GetStream (); 6 7//for easy display, stream the encrypted data bytes into a Base64 encoded string of 8 string encryptBase64 = Convert.tobase64strin
{Init ();//initializationPublishstream ()//Publish Video}}Private Function Publishstream (): void{Outstream=new NetStream (conn);Outstream.publish ("Test", "record");//publish parameter, test is the video name, the record representation is to be saved, if not saved with liveOutstream.attachcamera (camera);Invideo ();}Private Function Invideo (): void{//Receive videoInstream=new NetStream (conn);Instream.pla
Very good with flashmediaserver.
Give you a few pieces of as code.
Play
NC = new Netconnection ();
Nc.connect ("rtmp://127.0.0.1/cam02");
res = new NetStream (NC);
View.attachvideo (RES);
View.attachaudio (RES);
Res.play ("2");
Video
var cam = Camera.get ();
if (cam = = null)
{
Nocamerror.text = "No camera \ n or device is being occupied";
}
Else
{
Display video from the MAK and set like head
My_video.attachvideo (CAM);
My_v
Under pressure, I studied red5 and as3 last night and found it quite interesting.Red5 and fms are both good things, and they find learning things very fast under pressure. The code is as follows:Copy code // Pre-defined statementImport mx. utils. Delegate;// Create a basic network connection objectVar nc: NetConnection = new NetConnection ();// Connect to the local Red5 serverNc. connect ("rtmp: // localhost/online ");// Pass the nc that has established a connection with the red5 s
Code
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
Private
VaR
NC: netconnection
=
Null
;Private
VaR
NS: netstream
=
Null
; Public Function Myplay (URL: string ): Void {NC = New Netconnection ();NC. Connect ( Null );NS = New Netstream (NC );NS. Client = New Object ();NS. Play (URL ); // Playing FLV path,
);Vd_myvideo.attachcamera (camera);Microphone=microphone.getmicrophone ();}Private Function Netstatushandler (evt:netstatusevent): void{Trace (Evt.info.code);if (evt.info.code== "NetConnection.Connect.Success"){Btn_start.addeventlistener (mouseevent.click,startcommunicate);}Else{Alert.show ("FMS connection Failed" +evt.info.code);}}The code is relatively simple, do not understand can see my last articleHttp://www.cnblogs.com/aierong/archive/2009/01/10/flex_fms_video_start.html9. Implement button
classThe socket class provides the highest level of control in network programmingOverriding the Tcpreceive application with the socket class Public voidListen () {Socket listener=NewSocket (ADDRESSFAMILY.INTERNETWORK,SOCKETTYPE.STREAM,PROTOCOLTYPE.TCP); Listener. Bind (NewIPEndPoint (Ipaddress.any,2112)); Listener. Listen (0); Socket Socket=Listener. Accept (); Stream NetStream=NewNetworkStream (socket); StreamReader Reader=NewStreamReader (
necessarily placed in mongodobject, And the onsync is used for synchronization., Sometimes sending is also a very simple practice, how to define1. Define the method "myfun" on netstream or mongodobject"2. Use netstream. Send ("myfun") or mongodobject. Send ("myfun", myvar) to allow all clients"Myfun" on will be triggeredIv. Examples of possible interaction types1. The client transmits data to the server or
Two years ago, I used flvplayer on my website, similar to Tudou and youku.Today, we have made a flvplayer for Lite3.0.There were many twists and turns.It's not easy to copy the as2.0 code in flashplayer9 to lite3!-----------------------------------------------------------
Success! The functional interface of the entire flvplayer.The development process is not very difficult.However, to load network resources, first load local resources.The difference is that the resource path is different,The fo
With the FMS/red5 configuration, use flvplayerback to test the rtmp protocol. To further use netstream for development, we found that netstream. Play only supports HTTP and file protocols (refer to the Flash help ).Check the Internet for YouTube, 6rooms, and 56, and find that the playing protocols they use are also HTTP. As the Streaming Media Server, the FMS/red5 has been specially optimized. But why are t
is 0, it indicates that the flush function does not find a small audio package to be played. At this time, if the total playback time of the audio package in the linked list is greater than max_play_time, the parameter passed to flushlater () is minplaytime = 0, _ audiobuftimemax, indicating that you only need to find an audio package to play the video, so that the audio package is not found in every flush.
Otherwise, if the buffer time of the audio package in the linked list in
/// /// Host name or IP address/// /// Public String hostname{Get {return mstrhost ;}Set {mstrhost = value ;}}
/// /// Host port number/// /// Public int Port{Get {return mintport ;}Set {mintport = value ;}}
# Endregion
# Region private Method
/// /// Write data to the basic data stream accessed by the Network (send the command code)/// /// /// /// Private void writetonetstream (ref networkstream netstream, string command){String strtosend = command
NetConnection in the rtmp protocol specification.RTMP_ConnectStream (): Creates a NetStream in the rtmp protocol specification.RTMP_Read (): reads data from the server.RTMP_Close (): Close the RTMP connection.RTMP_Free (): Release the struct "RTMP ".CleanupSockets (): Disable Socket.NetStream and NetConnection are two logical structures in the RTMP protocol specification. NetStream is created on top of Net
computer, you can use the rtmp: // localhost/doc_connect/test abbreviation rtmp:/doc_connect/test to establish a connection. In this way, you can move this file to different servers without changing your code. However, if your flashmx and FCS are no longer on the same machine, you must specify the server URL.Create a network stream named out_ns for video, load camera to this stream, and publish this stream as myteststream. All these steps are completed in the publishme function.Function publish
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.