--- /dev/null
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.30501.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpServersExamples", "HttpServersExamples\HttpServersExamples.csproj", "{41EA8377-2483-4D2C-A56C-A1F90832FB69}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {41EA8377-2483-4D2C-A56C-A1F90832FB69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {41EA8377-2483-4D2C-A56C-A1F90832FB69}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {41EA8377-2483-4D2C-A56C-A1F90832FB69}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {41EA8377-2483-4D2C-A56C-A1F90832FB69}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
--- /dev/null
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+ </startup>
+</configuration>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{41EA8377-2483-4D2C-A56C-A1F90832FB69}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>HttpServersExamples</RootNamespace>
+ <AssemblyName>HttpServersExamples</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace HttpServersExamples
+{
+ class Program
+ {
+ private static AutoResetEvent autoEvent = new AutoResetEvent(false);
+
+ static void Main(string[] args)
+ {
+ HttpListener server = new HttpListener();
+
+ server.Prefixes.Add("http://127.0.0.1:10002/");
+
+ server.Start();
+
+ while(server.IsListening)
+ {
+ var asyncResult = server.BeginGetContext(ListenerCallback, server);
+ Thread.Sleep(3000);
+ }
+
+ }
+
+ private static void ListenerCallback(IAsyncResult result)
+ {
+ autoEvent.Set();
+ autoEvent.Reset();
+
+ HttpListener server = (HttpListener)result.AsyncState;
+
+ HttpListenerContext context = server.EndGetContext(result);
+
+ HandleRemoteRequest(context);
+ }
+
+ private static void HandleRemoteRequest(HttpListenerContext context)
+ {
+ HttpListenerRequest request = context.Request;
+
+ HttpListenerResponse response = context.Response;
+
+ string responseString = "<HTML><BODY>Hello World!</BODY></HTML>";
+ byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
+ response.ContentLength64 = buffer.Length;
+ using(Stream output = response.OutputStream)
+ {
+ output.Write(buffer, 0, buffer.Length);
+ }
+
+ int waitResult = WaitHandle.WaitAny(new[] { autoEvent }, TimeSpan.FromSeconds(30), false);
+
+ if (waitResult == 0 || waitResult == 1)
+ {
+ Console.WriteLine("Done...");
+ }
+ else if (waitResult == WaitHandle.WaitTimeout)
+ {
+ Console.WriteLine("Done by timeout");
+ }
+
+ }
+ }
+}
--- /dev/null
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// La información general sobre un ensamblado se controla mediante el siguiente
+// conjunto de atributos. Cambie estos atributos para modificar la información
+// asociada con un ensamblado.
+[assembly: AssemblyTitle("HttpServersExamples")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("HttpServersExamples")]
+[assembly: AssemblyCopyright("Copyright © 2014")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Si establece ComVisible como false, los tipos de este ensamblado no estarán visibles
+// para los componentes COM. Si necesita obtener acceso a un tipo de este ensamblado desde
+// COM, establezca el atributo ComVisible como true en este tipo.
+[assembly: ComVisible(false)]
+
+// El siguiente GUID sirve como identificador de typelib si este proyecto se expone a COM
+[assembly: Guid("adac396b-85c0-4896-b7b1-ec87e82d310f")]
+
+// La información de versión de un ensamblado consta de los cuatro valores siguientes:
+//
+// Versión principal
+// Versión secundaria
+// Número de compilación
+// Revisión
+//
+// Puede especificar todos los valores o establecer como predeterminados los números de compilación y de revisión
+// mediante el carácter '*', como se muestra a continuación:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
{
public class Clouds
{
- public int? all { get; set; }
+ public double? all { get; set; }
}
}
public Wind wind { get; set; }
public Rain rain { get; set; }
public Clouds clouds { get; set; }
- public int? dt { get; set; }
- public int? id { get; set; }
+ public long? dt { get; set; }
+ public long? id { get; set; }
public string name { get; set; }
- public int? cod { get; set; }
+ public long? cod { get; set; }
}
}
public class Main
{
public double? temp { get; set; }
- public int? pressure { get; set; }
- public int? humidity { get; set; }
+ public double? pressure { get; set; }
+ public double? humidity { get; set; }
public double? temp_min { get; set; }
public double? temp_max { get; set; }
}
{
public double? message { get; set; }
public string country { get; set; }
- public int? sunrise { get; set; }
- public int? sunset { get; set; }
+ public long? sunrise { get; set; }
+ public long? sunset { get; set; }
}
}
{
public class Weather
{
- public int? id { get; set; }
+ public long? id { get; set; }
public string main { get; set; }
public string description { get; set; }
public string icon { get; set; }
{
public class City
{
- public int? id { get; set; }
+ public long? id { get; set; }
public string name { get; set; }
public Coord coord { get; set; }
public string country { get; set; }
- public int? population { get; set; }
+ public long? population { get; set; }
}
}
{
public class List
{
- public int? dt { get; set; }
+ public long? dt { get; set; }
public Temp temp { get; set; }
public double? pressure { get; set; }
- public int? humidity { get; set; }
+ public double? humidity { get; set; }
public List<Weather> weather { get; set; }
public double? speed { get; set; }
- public int? deg { get; set; }
- public int? clouds { get; set; }
+ public double? deg { get; set; }
+ public double? clouds { get; set; }
public double? rain { get; set; }
}
}
{
public class Weather
{
- public int? id { get; set; }
+ public long? id { get; set; }
public string main { get; set; }
public string description { get; set; }
public string icon { get; set; }