Added simple C# example (#25)
diff --git a/http/get_simple/csharp/.gitignore b/http/get_simple/csharp/.gitignore
new file mode 100644
index 0000000..a9fbd58
--- /dev/null
+++ b/http/get_simple/csharp/.gitignore
@@ -0,0 +1,267 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# DNX
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+*_i.c
+*_p.c
+*_i.h
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# TODO: Comment the next line if you want to checkin your web deploy settings
+# but database connection strings (with potential passwords) will be unencrypted
+#*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/packages/*
+# except build/, which is used as an MSBuild target.
+!**/packages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/packages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+node_modules/
+orleans.codegen.cs
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# CodeRush
+.cr/
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Project-specific
+artifacts/
+
+# add .sln files back because they are ignored by the root .gitignore file
+!*.sln
diff --git a/http/get_simple/csharp/client/ArrowHttpClient.cs b/http/get_simple/csharp/client/ArrowHttpClient.cs
new file mode 100644
index 0000000..d23327b
--- /dev/null
+++ b/http/get_simple/csharp/client/ArrowHttpClient.cs
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Net.Http;
+using System.Threading.Tasks;
+using Apache.Arrow;
+using Apache.Arrow.Ipc;
+
+namespace ArrowHttpClient
+{
+ public class Program
+ {
+ public static async Task Main(string[] args)
+ {
+ string serverUri = "http://127.0.0.1:8008/";
+
+ DateTime startTime = DateTime.UtcNow;
+
+ HttpClient httpClient = new HttpClient
+ {
+ BaseAddress = new Uri(serverUri),
+ };
+
+ using (var stream = await httpClient.GetStreamAsync(serverUri))
+ using (var reader = new ArrowStreamReader(stream))
+ {
+ Console.WriteLine("Connected");
+
+ Schema schema = reader.Schema;
+ List<RecordBatch> batches = new List<RecordBatch>();
+
+ int numRows = 0;
+ RecordBatch batch;
+ while ((batch = await reader.ReadNextRecordBatchAsync()) != null)
+ {
+ numRows += batch.Length;
+ batches.Add(batch);
+ }
+
+ DateTime endTime = DateTime.UtcNow;
+
+ Console.WriteLine($"{numRows} records received");
+ Console.WriteLine($"{batches.Count} record batches received");
+ Console.WriteLine($"{(endTime - startTime).TotalSeconds} seconds elapsed");
+ }
+ }
+ }
+}
diff --git a/http/get_simple/csharp/client/Client.csproj b/http/get_simple/csharp/client/Client.csproj
new file mode 100644
index 0000000..9331140
--- /dev/null
+++ b/http/get_simple/csharp/client/Client.csproj
@@ -0,0 +1,12 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <TargetFramework>net8.0</TargetFramework>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <PackageReference Include="Apache.Arrow" Version="15.0.1" />
+ </ItemGroup>
+
+</Project>
diff --git a/http/get_simple/csharp/client/README.md b/http/get_simple/csharp/client/README.md
new file mode 100644
index 0000000..232cf90
--- /dev/null
+++ b/http/get_simple/csharp/client/README.md
@@ -0,0 +1,32 @@
+<!---
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+# HTTP GET Arrow Data: Simple C# Client Example
+
+This directory contains a minimal example of an HTTP client implemented in C#. The client:
+
+1. Sends an HTTP GET request to a server.
+2. Receives an HTTP 200 response from the server, with the response body containing an Arrow IPC stream of record batches.
+3. Adds the record batches to a list as they are received.
+
+To run this example, first start one of the server examples in the parent directory, then:
+
+```sh
+dotnet run -c Release
+```
diff --git a/http/get_simple/csharp/server/ArrowHttpServer.cs b/http/get_simple/csharp/server/ArrowHttpServer.cs
new file mode 100644
index 0000000..7273947
--- /dev/null
+++ b/http/get_simple/csharp/server/ArrowHttpServer.cs
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Threading.Tasks;
+using Apache.Arrow;
+using Apache.Arrow.Ipc;
+using Apache.Arrow.Types;
+
+namespace ArrowHttpServer
+{
+ public class Program
+ {
+ static readonly Schema schema = new Schema(
+ new Field[]
+ {
+ new Field("a", Int64Type.Default, true),
+ new Field("b", Int64Type.Default, true),
+ new Field("c", Int64Type.Default, true),
+ new Field("d", Int64Type.Default, true),
+ }, null);
+
+ static List<RecordBatch> GenerateBatches(int totalRecords = 100000000, int batchSize = 4096)
+ {
+ Random random = new Random();
+ IArrowArray[] columns = new IArrowArray[schema.FieldsList.Count];
+ for (int i = 0; i < columns.Length; i++)
+ {
+ byte[] dataBytes = new byte[batchSize * sizeof(long)];
+ random.NextBytes(dataBytes);
+ ArrowBuffer data = new ArrowBuffer(dataBytes);
+ byte[] validityBytes = new byte[batchSize / 8];
+ System.Array.Fill(validityBytes, (byte)0xff);
+ ArrowBuffer validity = new ArrowBuffer(validityBytes);
+
+ columns[i] = ArrowArrayFactory.BuildArray(new ArrayData(schema.FieldsList[i].DataType, batchSize, 0, 0, new [] { validity, data }, null));
+ }
+
+ List<RecordBatch> batches = new List<RecordBatch>(totalRecords);
+ using (RecordBatch batch = new RecordBatch(schema, columns, batchSize))
+ {
+ int records = 0;
+ while (records < totalRecords)
+ {
+ RecordBatch newBatch = batch.Clone();
+ if (records + batchSize > totalRecords)
+ {
+ int newLength = totalRecords - records;
+ newBatch = new RecordBatch(schema, newBatch.Arrays.Select(a => ArrowArrayFactory.Slice(a, 0, newLength)), newLength);
+ }
+
+ batches.Add(batch);
+ records += batchSize;
+ }
+ }
+
+ return batches;
+ }
+
+ public static async Task Main(string[] args)
+ {
+ string serverUri = "http://127.0.0.1:8008/";
+
+ HttpListener listener = new HttpListener();
+ listener.Prefixes.Add(serverUri);
+ listener.Start();
+
+ Console.Write("Generating data... ");
+ var batches = GenerateBatches();
+ Console.WriteLine("done.");
+
+ while (true)
+ {
+ Console.Write("Waiting... ");
+ var context = await listener.GetContextAsync();
+ Console.WriteLine("client connected");
+ DateTime startTime = DateTime.UtcNow;
+
+ context.Response.SendChunked = true;
+ context.Response.StatusCode = (int)HttpStatusCode.OK;
+ context.Response.ContentType = "application/vnd.apache.arrow.stream";
+
+ int numRows = 0;
+ using (context.Response.OutputStream)
+ using (var writer = new ArrowStreamWriter(context.Response.OutputStream, schema))
+ {
+ foreach (RecordBatch batch in batches)
+ {
+ await writer.WriteRecordBatchAsync(batch);
+ numRows += batch.Length;
+ }
+ }
+ DateTime endTime = DateTime.UtcNow;
+
+ Console.WriteLine("Done");
+ Console.WriteLine($"{numRows} records sent");
+ Console.WriteLine($"{batches.Count} record batches sent");
+ Console.WriteLine($"{(endTime - startTime).TotalSeconds} seconds elapsed");
+ }
+ }
+ }
+}
diff --git a/http/get_simple/csharp/server/README.md b/http/get_simple/csharp/server/README.md
new file mode 100644
index 0000000..9a7f087
--- /dev/null
+++ b/http/get_simple/csharp/server/README.md
@@ -0,0 +1,32 @@
+<!---
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+# HTTP GET Arrow Data: Simple C# Server Example
+
+This directory contains a minimal example of an HTTP server implemented in C#. The server:
+
+1. Creates a list of record batches and populates it with synthesized data.
+2. Listens for HTTP requests from clients.
+3. Upon receiving a request, sends an HTTP 200 response with the body containing an Arrow IPC stream of record batches.
+
+To run this example:
+
+```sh
+dotnet run -c Release
+```
diff --git a/http/get_simple/csharp/server/Server.csproj b/http/get_simple/csharp/server/Server.csproj
new file mode 100644
index 0000000..9331140
--- /dev/null
+++ b/http/get_simple/csharp/server/Server.csproj
@@ -0,0 +1,12 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <TargetFramework>net8.0</TargetFramework>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <PackageReference Include="Apache.Arrow" Version="15.0.1" />
+ </ItemGroup>
+
+</Project>