- vssprotocol01.zip
- VSSProtocol
- _ReSharper.VSSProtocol
- a97cfa68-c7c0-4928-ab36-0048f6ff04f0.Metadata
- CachesImage.bin
- e4b6b052-bb1b-4ae6-a8ae-f5809445cc0d.Metadata
- ReflectionCache.xml
- TodoCache
- WordIndex.New
- .format
- 0
- 27996041.dat
- 2
- 2140e1bb.dat
- 5
- 670e1070.dat
- VsspChat
- VSSProtocol.resharper
- VSSProtocol.resharper.user
- VSSProtocol.sln
- VSSProtocol
- bin
- Debug
- DataLayer
- Exceptions
- Messages
- obj
- Debug
- Refactor
- VSSProtocol.dll
- TempPE
- Properties
- Session
- States
- Users
- Utils
- VSSProtocol.csproj
- VSSProtocol.csproj.user
- vsspchat.zip
|
using System;
using System.Net;
using System.Net.Sockets;
using System.Security.Cryptography.X509Certificates;
using VSSProtocol.States;
namespace VSSProtocol.Users
{
/// <summary>
/// Listens for connections from VSSP network clients.
/// </summary>
public class VsspServer
{
/// <summary>
/// Listen on this port.
/// </summary>
private int port;
/// <summary>
/// The underline tcp server.
/// </summary>
private readonly TcpListener server;
/// <summary>
/// Certificate that server uses.
/// </summary>
private readonly X509Certificate2 serversCertificate;
/// <summary>
/// Initializes a new instance of the VsspServer class that listens on the specified port.
/// </summary>
/// <param name="port">Listen on this port.</param>
/// <param name="serversCertificate">Certificate that server uses.</param>
public VsspServer(int port, X509Certificate2 serversCertificate)
{
if (serversCertificate == null) throw new ArgumentNullException("serversCertificate");
this.port = port;
this.serversCertificate = serversCertificate;
// Local host.
IPAddress localAddr = IPAddress.Parse("127.0.0.1");
server = new TcpListener(localAddr, port);
// Start listening for client requests.
server.Start();
}
/// <summary>
/// Accepts a pending connection request
/// </summary>
/// <returns>A VsspClient used to send and receive data. </returns>
/// <exception cref="SocketException">Use the SocketException.ErrorCode property to obtain the specific
/// error code. When you have obtained this code, you can refer to the Windows Sockets version 2 API
/// error code documentation in MSDN for a detailed description of the error.</exception>
public VsspClient Accept()
{
// Accept connection.
TcpClient client = server.AcceptTcpClient();
VsspManager manager = new VsspManager(client.GetStream(), new HelloServerState(serversCertificate));
// Start handshake.
manager.StartHandshake();
// Return new client.
return new VsspClient(client, manager,"no", 100 );
}
///<summary>
///Closes the server.
///</summary>
///
///<exception cref="T:System.Net.Sockets.SocketException">Use the <see cref="P:System.Net.Sockets.SocketException.ErrorCode"></see> property to obtain the specific error code. When you have obtained this code, you can refer to the Windows�Sockets version 2 API error code documentation in MSDN for a detailed description of the error. </exception><PermissionSet><IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /><IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /><IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /></PermissionSet>
public void Stop()
{
server.Stop();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
A computer science master student at Bar Ilan University under the supervision of Dr. Gal Kaminka.
Dealing mainly with trajectory mining.