Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ Sphinx.Client
Open source .NET library which provides advanced client API to use Sphinx search server services, using Sphinx native binary protocol.

This repository contains public fork of original Sphinx.Client project located at Google Code (https://code.google.com/p/sphinx-dotnet-client/)

## Download

PM> Install-Package Sphinx.Client
4 changes: 2 additions & 2 deletions Sphinx.Client/Commands/Search/SearchQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,8 @@ internal void ValidateParameters()
{
ArgumentAssert.IsNotNull(Query, "Query");
ArgumentAssert.IsInRange(Offset, 0, int.MaxValue, "Offset");
ArgumentAssert.IsInRange(Limit, 1, int.MaxValue, "Limit");
ArgumentAssert.IsInRange(MaxMatches, 1, int.MaxValue, "MaxMatches");
ArgumentAssert.IsInRange(Limit, 0, int.MaxValue, "Limit");
ArgumentAssert.IsInRange(MaxMatches, 0, int.MaxValue, "MaxMatches");
ArgumentAssert.IsInRange(Cutoff, 0, int.MaxValue, "Cutoff");
ArgumentAssert.IsDefinedInEnum(typeof(MatchMode), MatchMode, "MatchMode");
ArgumentAssert.IsDefinedInEnum(typeof(ResultsSortMode), SortMode, "SortMode");
Expand Down
43 changes: 34 additions & 9 deletions Sphinx.Client/Network/TcpStreamAdapter.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading;
using Sphinx.Client.Helpers;
using Sphinx.Client.Resources;
Expand Down Expand Up @@ -44,6 +42,11 @@ public override int ReadBytes(byte[] buffer, int length)
_resetEvent.Reset();
Stream.BeginRead(buffer, length - state.BytesLeft, state.BytesLeft, ReadDataCallback, state);
WaitForNetworkData();

if (!string.IsNullOrEmpty(state.ErrorMessage))
{
throw new IOException(state.ErrorMessage);
}
}
return length;
}
Expand All @@ -66,19 +69,41 @@ private void WaitForNetworkData()
private void ReadDataCallback(IAsyncResult asyncResult)
{
NetworkReadState state = ((NetworkReadState)asyncResult.AsyncState);
if (!state.DataStream.CanRead)
throw new IOException(String.Format(Messages.Exception_CouldNotReadFromStream, state.BytesLeft, 0));
int actualBytes = state.DataStream.EndRead(asyncResult);
if (actualBytes == 0)
throw new IOException(String.Format(Messages.Exception_CouldNotReadFromStream, state.BytesLeft, actualBytes));
state.BytesLeft -= actualBytes;
_resetEvent.Set();
try
{
if (!state.DataStream.CanRead)
{
state.ErrorMessage = String.Format(Messages.Exception_CouldNotReadFromStream, state.BytesLeft, 0);
}
else
{

int actualBytes = state.DataStream.EndRead(asyncResult);
if (actualBytes == 0)
{
state.ErrorMessage = String.Format(Messages.Exception_CouldNotReadFromStream, state.BytesLeft, actualBytes);
}
else
{
state.BytesLeft -= actualBytes;
}
}
}
catch (Exception ex)
{
state.ErrorMessage = ex.ToString();
}
finally
{
_resetEvent.Set();
}
}

private class NetworkReadState
{
public Stream DataStream;
public int BytesLeft;
public string ErrorMessage;
}

#endregion
Expand Down
1 change: 1 addition & 0 deletions Sphinx.Client/NugetPack.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nuget pack Sphinx.Client.csproj -properties Configuration=Release
5 changes: 4 additions & 1 deletion Sphinx.Client/Sphinx.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand Down Expand Up @@ -206,6 +206,9 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="Sphinx.Client.nuspec" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\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.
Expand Down
15 changes: 15 additions & 0 deletions Sphinx.Client/Sphinx.Client.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>Sphinx.Client</id>
<version>1.0.2.0</version>
<title>Sphinx.Client</title>
<authors>eionov Eskat0n starasov</authors>
<owners>eionov Eskat0n starasov</owners>
<licenseUrl>http://www.gnu.org/licenses/lgpl.html</licenseUrl>
<projectUrl>https://github.com/s-tarasov/Sphinx.Client</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Open source .NET library which provides advanced client API to use Sphinx search server services, using Sphinx native binary protocol. It can be used from C#, VB.Net etc.</description>
<tags>Sphinx</tags>
</metadata>
</package>