Skip to content

Commit

Permalink
Merge pull request #17 from angelcalvasp/master
Browse files Browse the repository at this point in the history
Allow hostnames on ScsTcpClient
  • Loading branch information
hikalkan authored Sep 14, 2016
2 parents 6014284 + 42d3fc1 commit 2c50d11
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/Scs/Communication/Scs/Client/Tcp/ScsTcpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,32 @@ public ScsTcpClient(ScsTcpEndPoint serverEndPoint)
/// <returns>Ready communication channel to communicate</returns>
protected override ICommunicationChannel CreateCommunicationChannel()
{

EndPoint endpoint = null;

if (IsStringIp(_serverEndPoint.IpAddress))
{
endpoint = new IPEndPoint(IPAddress.Parse(_serverEndPoint.IpAddress), _serverEndPoint.TcpPort);
}
else
{
endpoint = new DnsEndPoint(_serverEndPoint.IpAddress, _serverEndPoint.TcpPort);
}

return new TcpCommunicationChannel(
TcpHelper.ConnectToServer(
new IPEndPoint(IPAddress.Parse(_serverEndPoint.IpAddress), _serverEndPoint.TcpPort),
endpoint,
ConnectTimeout
));


}

private bool IsStringIp(string address)
{
IPAddress ipAddress = null;
return IPAddress.TryParse(address, out ipAddress);
}

}
}

0 comments on commit 2c50d11

Please sign in to comment.