1. HttpListener sSocket = new HttpListener();
  2. sSocket.Prefixes.Add("http://127.0.0.1:8080/");
  3. sSocket.Start();
  4. sSocket.BeginGetContext(new AsyncCallback(GetContextCallBack), sSocket);
  5. System.Diagnostics.Process.Start("http://127.0.0.1:8080");
  6. button1.Enabled = false;
  7.  
  8. private void GetContextCallBack(IAsyncResult ar)
  9. {
  10. try
  11. {
  12. HttpListener sSocket = ar.AsyncState as HttpListener;
  13.  
  14. HttpListenerContext context = sSocket.EndGetContext(ar);
  15.  
  16. string jg = "<html><body><h1>测试页" + sSocket.IsListening + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff") + "</h1><h1>测试页</h1></body></html>";
  17. // context.Response.StatusCode = 200;
  18. context.Response.Headers.Add("Access-Control-Allow-Origin", "*");
  19. context.Response.Headers.Add("Server", "xx");
  20.  
  21. context.Response.ContentType = "text/html;charset=utf-8";
  22. context.Response.ContentEncoding = Encoding.UTF8;
  23. byte[] buffer = System.Text.Encoding.UTF8.GetBytes(jg);
  24. context.Response.ContentLength64 = buffer.Length;
  25. context.Response.OutputStream.Write(buffer, 0, buffer.Length);
  26.  
  27. Console.WriteLine(context.Request.Url.PathAndQuery);
  28. sSocket.BeginGetContext(new AsyncCallback(GetContextCallBack), sSocket);
  29.  
  30. }
  31. catch (Exception ex)
  32. {
  33. string d = ex.Message;
  34. }
  35.  
  36. }

  

  1. private static HttpListener listener;
  2.  
  3. public static void demo()
  4. {
  5. if (listener == null)
  6. {
  7. listener = new HttpListener();
  8. var url = "http://+:9876/";
  9. listener.Prefixes.Add(url);
  10. listener.Start();
  11. listener.BeginGetContext(MainProcess, null);
  12. };
  13. }
  14.  
  15. private static void MainProcess(IAsyncResult ar)
  16. {
  17. var context = listener.EndGetContext(ar);
  18. listener.BeginGetContext(MainProcess, null);
  19.  
  20. var response = context.Response;
  21. response.AddHeader("Server", "M");
  22. var request = context.Request;
  23. var path = request.Url.LocalPath;
  24. if (path.StartsWith("/") || path.StartsWith("\\"))
  25. path = path.Substring(1);
  26. var sb = new StringBuilder("输入请求:");
  27. sb.AppendLine(path);
  28. var visit = path.Split(new char[] { '/', '\\' }, 2);
  29. if (visit.Length > 0)
  30. {
  31. var cmd = visit[0].ToLower();
  32. sb.AppendLine(string.Format("执行命令:{0}", cmd));
  33. sb.AppendLine(string.Format("另外有{0}个参数", visit.Length - 1 + request.QueryString.Count));
  34. }
  35. sb.AppendLine(DateTime.Now.ToString());
  36. response.ContentType = "text/plain;charset=UTF-8";
  37. var result = Encoding.UTF8.GetBytes(sb.ToString());
  38. response.ContentLength64 = result.Length;
  39.  
  40. using (var stream = response.OutputStream)
  41. {
  42. stream.Write(result, 0, result.Length);
  43. }
  44. }

  --------hao.........

  1. using System;
  2. using System.Collections;
  3. using System.IO;
  4. using System.Net;
  5. using System.Net.Sockets;
  6. using System.Threading;
  7.  
  8. namespace Bend.Util {
  9.  
  10. public class HttpProcessor {
  11. public TcpClient socket;
  12. public HttpServer srv;
  13.  
  14. private Stream inputStream;
  15. public StreamWriter outputStream;
  16.  
  17. public String http_method;
  18. public String http_url;
  19. public String http_protocol_versionstring;
  20. public Hashtable httpHeaders = new Hashtable();
  21.  
  22. private static int MAX_POST_SIZE = 10 * 1024 * 1024; // 10MB
  23.  
  24. public HttpProcessor(TcpClient s, HttpServer srv) {
  25. this.socket = s;
  26. this.srv = srv;
  27. }
  28.  
  29. private string streamReadLine(Stream inputStream) {
  30. int next_char;
  31. string data = "";
  32. while (true) {
  33. next_char = inputStream.ReadByte();
  34. if (next_char == '\n') { break; }
  35. if (next_char == '\r') { continue; }
  36. if (next_char == -1) { Thread.Sleep(1); continue; };
  37. data += Convert.ToChar(next_char);
  38. }
  39. return data;
  40. }
  41. public void process() {
  42. // we can't use a StreamReader for input, because it buffers up extra data on us inside it's
  43. // "processed" view of the world, and we want the data raw after the headers
  44. inputStream = new BufferedStream(socket.GetStream());
  45.  
  46. // we probably shouldn't be using a streamwriter for all output from handlers either
  47. outputStream = new StreamWriter(new BufferedStream(socket.GetStream()));
  48. try {
  49. parseRequest();
  50. readHeaders();
  51. if (http_method.Equals("GET")) {
  52. handleGETRequest();
  53. } else if (http_method.Equals("POST")) {
  54. handlePOSTRequest();
  55. }
  56. } catch (Exception e) {
  57. Console.WriteLine("Exception: " + e.ToString());
  58. writeFailure();
  59. }
  60. outputStream.Flush();
  61. // bs.Flush(); // flush any remaining output
  62. inputStream = null; outputStream = null; // bs = null;
  63. socket.Close();
  64. }
  65.  
  66. public void parseRequest() {
  67. String request = streamReadLine(inputStream);
  68. string[] tokens = request.Split(' ');
  69. if (tokens.Length != 3) {
  70. throw new Exception("invalid http request line");
  71. }
  72. http_method = tokens[0].ToUpper();
  73. http_url = tokens[1];
  74. http_protocol_versionstring = tokens[2];
  75.  
  76. Console.WriteLine("starting: " + request);
  77. }
  78.  
  79. public void readHeaders() {
  80. Console.WriteLine("readHeaders()");
  81. String line;
  82. while ((line = streamReadLine(inputStream)) != null) {
  83. if (line.Equals("")) {
  84. Console.WriteLine("got headers");
  85. return;
  86. }
  87.  
  88. int separator = line.IndexOf(':');
  89. if (separator == -1) {
  90. throw new Exception("invalid http header line: " + line);
  91. }
  92. String name = line.Substring(0, separator);
  93. int pos = separator + 1;
  94. while ((pos < line.Length) && (line[pos] == ' ')) {
  95. pos++; // strip any spaces
  96. }
  97.  
  98. string value = line.Substring(pos, line.Length - pos);
  99. Console.WriteLine("header: {0}:{1}",name,value);
  100. httpHeaders[name] = value;
  101. }
  102. }
  103.  
  104. public void handleGETRequest() {
  105. srv.handleGETRequest(this);
  106. }
  107.  
  108. private const int BUF_SIZE = 4096;
  109. public void handlePOSTRequest() {
  110. // this post data processing just reads everything into a memory stream.
  111. // this is fine for smallish things, but for large stuff we should really
  112. // hand an input stream to the request processor. However, the input stream
  113. // we hand him needs to let him see the "end of the stream" at this content
  114. // length, because otherwise he won't know when he's seen it all!
  115.  
  116. Console.WriteLine("get post data start");
  117. int content_len = 0;
  118. MemoryStream ms = new MemoryStream();
  119. if (this.httpHeaders.ContainsKey("Content-Length")) {
  120. content_len = Convert.ToInt32(this.httpHeaders["Content-Length"]);
  121. if (content_len > MAX_POST_SIZE) {
  122. throw new Exception(
  123. String.Format("POST Content-Length({0}) too big for this simple server",
  124. content_len));
  125. }
  126. byte[] buf = new byte[BUF_SIZE];
  127. int to_read = content_len;
  128. while (to_read > 0) {
  129. Console.WriteLine("starting Read, to_read={0}",to_read);
  130.  
  131. int numread = this.inputStream.Read(buf, 0, Math.Min(BUF_SIZE, to_read));
  132. Console.WriteLine("read finished, numread={0}", numread);
  133. if (numread == 0) {
  134. if (to_read == 0) {
  135. break;
  136. } else {
  137. throw new Exception("client disconnected during post");
  138. }
  139. }
  140. to_read -= numread;
  141. ms.Write(buf, 0, numread);
  142. }
  143. ms.Seek(0, SeekOrigin.Begin);
  144. }
  145. Console.WriteLine("get post data end");
  146. srv.handlePOSTRequest(this, new StreamReader(ms));
  147.  
  148. }
  149.  
  150. public void writeSuccess() {
  151. outputStream.WriteLine("HTTP/1.0 200 OK");
  152. outputStream.WriteLine("Content-Type: text/html");
  153. outputStream.WriteLine("Connection: close");
  154. outputStream.WriteLine("");
  155. }
  156.  
  157. public void writeFailure() {
  158. outputStream.WriteLine("HTTP/1.0 404 File not found");
  159. outputStream.WriteLine("Connection: close");
  160. outputStream.WriteLine("");
  161. }
  162. }
  163.  
  164. public abstract class HttpServer {
  165.  
  166. protected int port;
  167. TcpListener listener;
  168. bool is_active = true;
  169.  
  170. public HttpServer(int port) {
  171. this.port = port;
  172. }
  173.  
  174. public void listen() {
  175. listener = new TcpListener(port);
  176. listener.Start();
  177. while (is_active) {
  178. TcpClient s = listener.AcceptTcpClient();
  179. HttpProcessor processor = new HttpProcessor(s, this);
  180. Thread thread = new Thread(new ThreadStart(processor.process));
  181. thread.Start();
  182. Thread.Sleep(1);
  183. }
  184. }
  185.  
  186. public abstract void handleGETRequest(HttpProcessor p);
  187. public abstract void handlePOSTRequest(HttpProcessor p, StreamReader inputData);
  188. }
  189.  
  190. public class MyHttpServer : HttpServer {
  191. public MyHttpServer(int port)
  192. : base(port) {
  193. }
  194. public override void handleGETRequest(HttpProcessor p) {
  195. Console.WriteLine("request: {0}", p.http_url);
  196. p.writeSuccess();
  197. p.outputStream.WriteLine("<html><body><h1>test server</h1>");
  198. p.outputStream.WriteLine("Current Time: " + DateTime.Now.ToString());
  199. p.outputStream.WriteLine("url : {0}", p.http_url);
  200.  
  201. p.outputStream.WriteLine("<form method=post action=/form>");
  202. p.outputStream.WriteLine("<input type=text name=foo value=foovalue>");
  203. p.outputStream.WriteLine("<input type=submit name=bar value=barvalue>");
  204. p.outputStream.WriteLine("</form>");
  205. }
  206.  
  207. public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData) {
  208. Console.WriteLine("POST request: {0}", p.http_url);
  209. string data = inputData.ReadToEnd();
  210.  
  211. p.outputStream.WriteLine("<html><body><h1>test server</h1>");
  212. p.outputStream.WriteLine("<a href=/test>return</a><p>");
  213. p.outputStream.WriteLine("postbody: <pre>{0}</pre>", data);
  214.  
  215. }
  216. }
  217.  
  218. public class TestMain {
  219. public static int Main(String[] args) {
  220. HttpServer httpServer;
  221. if (args.GetLength(0) > 0) {
  222. httpServer = new MyHttpServer(Convert.ToInt16(args[0]));
  223. } else {
  224. httpServer = new MyHttpServer(8080);
  225. }
  226. Thread thread = new Thread(new ThreadStart(httpServer.listen));
  227. thread.Start();
  228. return 0;
  229. }
  230.  
  231. }
  232.  
  233. }

  

-----------------------------------------------------

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Net;
  5. using System.Net.Sockets;
  6. using System.Threading;
  7. using System.IO;
  8.  
  9. namespace CSocketServer
  10. {
  11. public class SocketObject
  12. {
  13. public Socket CSocket = null;
  14. public const int BufferSize = 8;
  15. public byte[] Buffer = new byte[BufferSize];
  16. public StringBuilder DataBuilder = new StringBuilder();
  17. }
  18.  
  19. class Program
  20. {
  21. static void Main(string[] args)
  22. {
  23. Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  24.  
  25. IPEndPoint point = new IPEndPoint(IPAddress.Any, 55000);
  26.  
  27. socket.Bind(point);
  28. socket.Listen(100);
  29.  
  30. Console.WriteLine("Waiting For Client Connect...");
  31.  
  32. socket.BeginAccept(new AsyncCallback(AcceptCallBack), socket);
  33. Console.Read();
  34. }
  35.  
  36. static void AcceptCallBack(IAsyncResult ar)
  37. {
  38. Socket socket = (Socket)ar.AsyncState;
  39. Socket handler = socket.EndAccept(ar);
  40. socket.BeginAccept(new AsyncCallback(AcceptCallBack), socket);
  41. SocketObject obj = new SocketObject();
  42. obj.CSocket = handler;
  43. handler.BeginReceive(obj.Buffer, 0, SocketObject.BufferSize, SocketFlags.None,
  44. new AsyncCallback(ReceiveCallBack), obj);
  45. }
  46.  
  47. static void ReceiveCallBack(IAsyncResult ar)
  48. {
  49. SocketObject obj = (SocketObject)ar.AsyncState;
  50. Socket socket = obj.CSocket;
  51.  
  52. int bytesRead = socket.EndReceive(ar);
  53. string data = string.Empty;
  54. if (bytesRead > 0)
  55. {
  56. obj.DataBuilder.Append(Encoding.Default.GetString(obj.Buffer, 0, bytesRead));
  57.  
  58. socket.BeginReceive(obj.Buffer, 0, SocketObject.BufferSize, SocketFlags.None,
  59. new AsyncCallback(ReceiveCallBack), obj);
  60. }
  61. else
  62. {
  63. File.WriteAllText(string.Format(@"D:\{0}.txt", DateTime.Now.ToString("MMddHHmmssfff")), obj.DataBuilder.ToString());
  64. // Console.WriteLine(obj.DataBuilder.ToString());
  65. Console.WriteLine("Received {0} Bytes Data...", Encoding.Default.GetBytes(obj.DataBuilder.ToString()).Length);
  66. }
  67.  
  68. }
  69. }
  70. }

  

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Text;
  6. using System.Threading;
  7. using System.Web;
  8. using System.IO;
  9. using Newtonsoft.Json;
  10.  
  11. namespace HttpListenerApp
  12. {
  13. /// <summary>
  14. /// HttpRequest逻辑处理
  15. /// </summary>
  16. public class HttpProvider
  17. {
  18.  
  19. private static HttpListener httpFiledownload; //文件下载处理请求监听
  20. private static HttpListener httOtherRequest; //其他超做请求监听
  21.  
  22. /// <summary>
  23. /// 开启HttpListener监听
  24. /// </summary>
  25. public static void Init()
  26. {
  27. httpFiledownload = new HttpListener(); //创建监听实例
  28. httpFiledownload.Prefixes.Add("http://10.0.0.217:20009/FileManageApi/Download/"); //添加监听地址 注意是以/结尾。
  29. httpFiledownload.Start(); //允许该监听地址接受请求的传入。
  30. Thread ThreadhttpFiledownload = new Thread(new ThreadStart(GethttpFiledownload)); //创建开启一个线程监听该地址得请求
  31. ThreadhttpFiledownload.Start();
  32.  
  33. httOtherRequest = new HttpListener();
  34. httOtherRequest.Prefixes.Add("http://10.0.0.217:20009/BehaviorApi/EmailSend/"); //添加监听地址 注意是以/结尾。
  35. httOtherRequest.Start(); //允许该监听地址接受请求的传入。
  36. Thread ThreadhttOtherRequest = new Thread(new ThreadStart(GethttOtherRequest));
  37. ThreadhttOtherRequest.Start();
  38. }
  39.  
  40. /// <summary>
  41. /// 执行文件下载处理请求监听行为
  42. /// </summary>
  43. public static void GethttpFiledownload()
  44. {
  45. while (true)
  46. {
  47. HttpListenerContext requestContext = httpFiledownload.GetContext(); //接受到新的请求
  48. try
  49. {
  50. //reecontext 为开启线程传入的 requestContext请求对象
  51. Thread subthread = new Thread(new ParameterizedThreadStart((reecontext) =>
  52. {
  53. Console.WriteLine("执行文件处理请求监听行为");
  54.  
  55. var request = (HttpListenerContext)reecontext;
  56. var image = HttpUtility.UrlDecode(request.Request.QueryString["imgname"]); //接受GET请求过来的参数;
  57. string filepath = AppDomain.CurrentDomain.BaseDirectory + image;
  58. if (!File.Exists(filepath))
  59. {
  60. filepath = AppDomain.CurrentDomain.BaseDirectory + "default.jpg"; //下载默认图片
  61. }
  62. using (FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read))
  63. {
  64. byte[] buffer = new byte[fs.Length];
  65. fs.Read(buffer, 0, (int)fs.Length); //将文件读到缓存区
  66. request.Response.StatusCode = 200;
  67. request.Response.Headers.Add("Access-Control-Allow-Origin", "*");
  68. request.Response.ContentType = "image/jpg";
  69. request.Response.ContentLength64 = buffer.Length;
  70. var output = request.Response.OutputStream; //获取请求流
  71. output.Write(buffer, 0, buffer.Length); //将缓存区的字节数写入当前请求流返回
  72. output.Close();
  73. }
  74. }));
  75. subthread.Start(requestContext); //开启处理线程处理下载文件
  76. }
  77. catch (Exception ex)
  78. {
  79. try
  80. {
  81. requestContext.Response.StatusCode = 500;
  82. requestContext.Response.ContentType = "application/text";
  83. requestContext.Response.ContentEncoding = Encoding.UTF8;
  84. byte[] buffer = System.Text.Encoding.UTF8.GetBytes("System Error");
  85. //对客户端输出相应信息.
  86. requestContext.Response.ContentLength64 = buffer.Length;
  87. System.IO.Stream output = requestContext.Response.OutputStream;
  88. output.Write(buffer, 0, buffer.Length);
  89. //关闭输出流,释放相应资源
  90. output.Close();
  91. }
  92. catch { }
  93. }
  94. }
  95. }
  96.  
  97. /// <summary>
  98. /// 执行其他超做请求监听行为
  99. /// </summary>
  100. public static void GethttOtherRequest()
  101. {
  102. while (true)
  103. {
  104. HttpListenerContext requestContext = httOtherRequest.GetContext(); //接受到新的请求
  105. try
  106. {
  107. //reecontext 为开启线程传入的 requestContext请求对象
  108. Thread subthread = new Thread(new ParameterizedThreadStart((reecontext) =>
  109. {
  110. Console.WriteLine("执行其他超做请求监听行为");
  111. var request = (HttpListenerContext)reecontext;
  112. var msg = HttpUtility.UrlDecode(request.Request.QueryString["behavior"]); //接受GET请求过来的参数;
  113. //在此处执行你需要进行的操作>>比如什么缓存数据读取,队列消息处理,邮件消息队列添加等等。
  114.  
  115. request.Response.StatusCode = 200;
  116. request.Response.Headers.Add("Access-Control-Allow-Origin", "*");
  117. request.Response.ContentType = "application/json";
  118. requestContext.Response.ContentEncoding = Encoding.UTF8;
  119. byte[] buffer = System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { success = true, behavior = msg }));
  120. request.Response.ContentLength64 = buffer.Length;
  121. var output = request.Response.OutputStream;
  122. output.Write(buffer, 0, buffer.Length);
  123. output.Close();
  124. }));
  125. subthread.Start(requestContext); //开启处理线程处理下载文件
  126. }
  127. catch (Exception ex)
  128. {
  129. try
  130. {
  131. requestContext.Response.StatusCode = 500;
  132. requestContext.Response.ContentType = "application/text";
  133. requestContext.Response.ContentEncoding = Encoding.UTF8;
  134. byte[] buffer = System.Text.Encoding.UTF8.GetBytes("System Error");
  135. //对客户端输出相应信息.
  136. requestContext.Response.ContentLength64 = buffer.Length;
  137. System.IO.Stream output = requestContext.Response.OutputStream;
  138. output.Write(buffer, 0, buffer.Length);
  139. //关闭输出流,释放相应资源
  140. output.Close();
  141. }
  142. catch { }
  143. }
  144. }
  145. }
  146. }
  147. }

  ----------------------------------------

  1. private static void AddFireWallPort(int port)
  2. {
  3. string argsDll = String.Format(@"firewall set portopening TCP {0} ENABLE", port);
  4. ProcessStartInfo psi = new ProcessStartInfo("netsh", argsDll);
  5. psi.Verb = "runas";
  6. psi.CreateNoWindow = true;
  7. psi.WindowStyle = ProcessWindowStyle.Hidden;
  8. psi.UseShellExecute = false;
  9. Process.Start(psi).WaitForExit();
  10. }

  

Socket HttpListen的更多相关文章

  1. socket读写返回值的处理

    在调用socket读写函数read(),write()时,都会有返回值.如果没有正确处理返回值,就可能引入一些问题 总结了以下几点 1当read()或者write()函数返回值大于0时,表示实际从缓冲 ...

  2. Socket聊天程序——Common

    写在前面: 上一篇记录了Socket聊天程序的客户端设计,为了记录的完整性,这里还是将Socket聊天的最后一个模块--Common模块记录一下.Common的设计如下: 功能说明: Common模块 ...

  3. Socket聊天程序——客户端

    写在前面: 上周末抽点时间把自己写的一个简单Socket聊天程序的初始设计和服务端细化设计记录了一下,周二终于等来毕业前考的软考证书,然后接下来就是在加班的日子度过了,今天正好周五,打算把客户端的详细 ...

  4. Socket聊天程序——服务端

    写在前面: 昨天在博客记录自己抽空写的一个Socket聊天程序的初始设计,那是这个程序的整体设计,为了完整性,今天把服务端的设计细化记录一下,首页贴出Socket聊天程序的服务端大体设计图,如下图: ...

  5. Socket聊天程序——初始设计

    写在前面: 可能是临近期末了,各种课程设计接踵而来,最近在csdn上看到2个一样问答(问题A,问题B),那就是编写一个基于socket的聊天程序,正好最近刚用socket做了一些事,出于兴趣,自己抽了 ...

  6. Java中的Socket的用法

                                   Java中的Socket的用法 Java中的Socket分为普通的Socket和NioSocket. 普通Socket的用法 Java中的 ...

  7. Android Socket连接PC出错问题及解决

    最近测试问题:Android 通过Socket链接电脑,ip和端口都是正确的,也在同一网段,可android端就是报异常如下: 解决办法:测试电脑的防火墙可能开着,在控制面板把防火墙打开即可.

  8. Linux下的C Socket编程 -- server端的继续研究

    Linux下的C Socket编程(四) 延长server的生命周期 在前面的一个个例子中,server在处理完一个连接后便会立即结束掉自己,然而这种server并不科学啊,server应该是能够一直 ...

  9. Mono 3.2.3 Socket功能迎来一稳定的版本

    由于兴趣自己业余时间一直在搞.net下面的通讯应用,mono的存在得以让.NET程序轻松运行在Linux之下.不过经过多尝试Socket相关功能在Mono下的表现并不理想.不管性能还是吞吐能力方面离我 ...

随机推荐

  1. linux常用命名汇总:自用,持续更新

    1.查看磁盘空间大小 df -hl 查看磁盘剩余空间 df -h 查看每个根路径的分区大小 du -sh [目录名] 返回该目录的大小 du -sm [文件夹] 返回该文件夹总M数 du -h [目录 ...

  2. Java中在时间戳计算的过程中遇到的数据溢出问题

    背景 今天在跑定时任务的过程中,发现有一个任务在设置数据的查询时间范围异常,出现了开始时间戳比结束时间戳大的奇怪现象,计算时间戳的代码大致如下. package com.lingyejun.authe ...

  3. 团队作业-Beta冲刺(3/4)

    队名:软工9组 组长博客:https://www.cnblogs.com/cmlei/ 作业博客:https://edu.cnblogs.com/campus/fzu/SoftwareEngineer ...

  4. C# default(T)关键字

    C#关键词default函数,default(T)可以得到该类型的默认值. C#在类初始化时,会给未显示赋值的字段.属性赋上默认值,但是值变量却不会. 值变量可以使用默认构造函数赋值,或者使用defa ...

  5. FFmpeg av_seek_frame规律详解

    本帖最后由 TangMonk 于 2016-7-27 10:26 编辑 1 av_seek_frame对视频进行跳转规律 1.1 flags参数 #define AVSEEK_FLAG_BACKWAR ...

  6. Android adb命令打印activity堆栈

    ubuntu系统: adb shell dumpsys activity activities | sed -En -e '/Running activities/,/Run #0/p' window ...

  7. Spring MVC -- 转换器和格式化

    在Spring MVC -- 数据绑定和表单标签库中我们已经见证了数据绑定的威力,并学习了如何使用表单标签库中的标签.但是,Spring的数据绑定并非没有任何限制.有案例表明,Spring在如何正确绑 ...

  8. 【linux基础】ubuntu实现双屏显示

    前言 之前博主没有使用NVIDIA时候已经可以实现双屏显示(拼接类型),但是,安装NVIDIA驱动使用CUDA之后这个功能就消失了,需要重新配置. 实现方式 1. 使用Intel集成显卡时实现双屏拼接 ...

  9. Markdown Html高级功能 测试用例

    插入音频 后台样式代码: #cnblogs_post_body .music { height: 140px; /*padding-bottom: 14.39%;*/ /* 16:9 */ posit ...

  10. ES(ElasticSearch)文档的表现形式以及增删改查

    1. ES中的文档 ES是面向文档(document oriented)的,这意味着它可以存储整个对象或文档(document).然而它不仅仅是存储,还会索引(index)每个文档的内容使之可以被搜索 ...