First commit
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
</startup>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
</startup>
|
||||
</configuration>
|
||||
@@ -1,52 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" 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>{0AA862E1-2247-4CA7-8324-FBD7C5959CAF}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>ClientTest</RootNamespace>
|
||||
<AssemblyName>ClientTest</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</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.Net.Http" />
|
||||
<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" />
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" 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>{0AA862E1-2247-4CA7-8324-FBD7C5959CAF}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>ClientTest</RootNamespace>
|
||||
<AssemblyName>ClientTest</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</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.Net.Http" />
|
||||
<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" />
|
||||
</Project>
|
||||
@@ -1,82 +1,82 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
|
||||
public class SynchronousSocketClient
|
||||
{
|
||||
|
||||
public static void StartClient()
|
||||
{
|
||||
// Data buffer for incoming data.
|
||||
byte[] bytes = new byte[512];
|
||||
|
||||
// Connect to a remote device.
|
||||
try
|
||||
{
|
||||
// Establish the remote endpoint for the socket.
|
||||
// This example uses port 5000 on the local computer.
|
||||
IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
|
||||
IPAddress ipAddress = IPAddress.Parse("192.168.0.109");
|
||||
IPEndPoint remoteEP = new IPEndPoint(ipAddress, 5000);
|
||||
|
||||
// Create a TCP/IP socket.
|
||||
Socket sender = new Socket(ipAddress.AddressFamily,
|
||||
SocketType.Dgram, ProtocolType.Udp);
|
||||
|
||||
// Connect the socket to the remote endpoint. Catch any errors.
|
||||
try
|
||||
{
|
||||
//sender.Connect(remoteEP);
|
||||
|
||||
//Console.WriteLine("Socket connected to {0}",
|
||||
// sender.RemoteEndPoint.ToString());
|
||||
|
||||
// Encode the data string into a byte array.
|
||||
byte[] msg = Encoding.ASCII.GetBytes("This is a test<EOF>");
|
||||
|
||||
// Send the data through the socket.
|
||||
int bytesSent = sender.SendTo(msg, remoteEP);
|
||||
|
||||
// Creates an IPEndPoint to capture the identity of the sending host.
|
||||
IPEndPoint sendingEndpoint = new IPEndPoint(IPAddress.Any, 0);
|
||||
EndPoint senderRemote = (EndPoint)sendingEndpoint;
|
||||
|
||||
// Receive the response from the remote device.
|
||||
while(true)
|
||||
{
|
||||
int bytesRec = sender.ReceiveFrom(bytes, ref senderRemote);
|
||||
Console.WriteLine("Echoed test = {0}", Encoding.ASCII.GetString(bytes, 0, bytesRec));
|
||||
}
|
||||
|
||||
// Release the socket.
|
||||
sender.Shutdown(SocketShutdown.Both);
|
||||
sender.Close();
|
||||
|
||||
}
|
||||
catch (ArgumentNullException ane)
|
||||
{
|
||||
Console.WriteLine("ArgumentNullException : {0}", ane.ToString());
|
||||
}
|
||||
catch (SocketException se)
|
||||
{
|
||||
Console.WriteLine("SocketException : {0}", se.ToString());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("Unexpected exception : {0}", e.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public static int Main(String[] args)
|
||||
{
|
||||
StartClient();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
|
||||
public class SynchronousSocketClient
|
||||
{
|
||||
|
||||
public static void StartClient()
|
||||
{
|
||||
// Data buffer for incoming data.
|
||||
byte[] bytes = new byte[512];
|
||||
|
||||
// Connect to a remote device.
|
||||
try
|
||||
{
|
||||
// Establish the remote endpoint for the socket.
|
||||
// This example uses port 5000 on the local computer.
|
||||
IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
|
||||
IPAddress ipAddress = IPAddress.Parse("192.168.0.109");
|
||||
IPEndPoint remoteEP = new IPEndPoint(ipAddress, 5000);
|
||||
|
||||
// Create a TCP/IP socket.
|
||||
Socket sender = new Socket(ipAddress.AddressFamily,
|
||||
SocketType.Dgram, ProtocolType.Udp);
|
||||
|
||||
// Connect the socket to the remote endpoint. Catch any errors.
|
||||
try
|
||||
{
|
||||
//sender.Connect(remoteEP);
|
||||
|
||||
//Console.WriteLine("Socket connected to {0}",
|
||||
// sender.RemoteEndPoint.ToString());
|
||||
|
||||
// Encode the data string into a byte array.
|
||||
byte[] msg = Encoding.ASCII.GetBytes("This is a test<EOF>");
|
||||
|
||||
// Send the data through the socket.
|
||||
int bytesSent = sender.SendTo(msg, remoteEP);
|
||||
|
||||
// Creates an IPEndPoint to capture the identity of the sending host.
|
||||
IPEndPoint sendingEndpoint = new IPEndPoint(IPAddress.Any, 0);
|
||||
EndPoint senderRemote = (EndPoint)sendingEndpoint;
|
||||
|
||||
// Receive the response from the remote device.
|
||||
while(true)
|
||||
{
|
||||
int bytesRec = sender.ReceiveFrom(bytes, ref senderRemote);
|
||||
Console.WriteLine("Echoed test = {0}", Encoding.ASCII.GetString(bytes, 0, bytesRec));
|
||||
}
|
||||
|
||||
// Release the socket.
|
||||
sender.Shutdown(SocketShutdown.Both);
|
||||
sender.Close();
|
||||
|
||||
}
|
||||
catch (ArgumentNullException ane)
|
||||
{
|
||||
Console.WriteLine("ArgumentNullException : {0}", ane.ToString());
|
||||
}
|
||||
catch (SocketException se)
|
||||
{
|
||||
Console.WriteLine("SocketException : {0}", se.ToString());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("Unexpected exception : {0}", e.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public static int Main(String[] args)
|
||||
{
|
||||
StartClient();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ClientTest")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ClientTest")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("0aa862e1-2247-4ca7-8324-fbd7c5959caf")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ClientTest")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ClientTest")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("0aa862e1-2247-4ca7-8324-fbd7c5959caf")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
||||
Reference in New Issue
Block a user