本文整理汇总了C#中ProtocolType类的典型用法代码示例。如果您正苦于以下问题:C# ProtocolType类的具体用法?C# ProtocolType怎么用?C# ProtocolType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProtocolType类属于命名空间,在下文中一共展示了ProtocolType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SocketAsyncClient
/// <summary>
///
/// </summary>
public SocketAsyncClient(IPEndPoint remoteEndPoint, int bufferSize, AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
{
_remoteEndPoint = remoteEndPoint;
_client = new Socket(addressFamily, socketType, protocolType);
socketObject = new SocketObject(Guid.NewGuid(), _client);
int maxConnection = 1;
int numOfSaeaForRecSend = maxConnection * OpsToPreAlloc;
_readWritePool = new SocketAsyncPool(numOfSaeaForRecSend);
int numSize = numOfSaeaForRecSend * bufferSize;
_bufferManager = new BufferManager(numSize, bufferSize);
_bufferManager.InitBuffer();
_saeaProxy = new SocketAsyncEventArgsProxy(bufferSize);
_saeaProxy.ReceiveCompleted += OnReceiveCompleted;
_saeaProxy.SendCompleted += OnSendCompleted;
_saeaProxy.ClosedHandle += OnSocketClosing;
SocketAsyncEventArgs saea;
for (int i = 0; i < numOfSaeaForRecSend; i++)
{
saea = _saeaProxy.CreateNewSaea();
_bufferManager.SetBuffer(saea);
saea.UserToken = new DataToken(saea.Offset);
_readWritePool.Push(saea);
}
}
示例2: init
/// <summary>
/// Initializes the socket
/// </summary>`
public void init(int offset, string ipAddress)
{
socketType = SocketType.Stream;
protocolType = ProtocolType.Tcp;
//addressFamily = AddressFamily.InterNetwork;
addressFamily = AddressFamily.InterNetwork;
try
{
ipEntry = Dns.GetHostEntry(Dns.GetHostName());
IPAddress[] addr = ipEntry.AddressList;
//endpoint = new IPEndPoint(addr[0], port);
for (int i = 0; i < addr.Length; i++)
{
Console.WriteLine("IP Address {0}: {1} ", i, addr[i].ToString());
}
if (ipAddress == "")
{
address = addr[addr.Length - offset];
}
else
{
address = IPAddress.Parse(ipAddress);
}
Console.WriteLine("Using the Address {0}: {1}", address.ToString(), port);
endpoint = new IPEndPoint(address, port);
}
catch (SocketException ex)
{
System.Console.WriteLine(ex.Message);
}
createSocket();
}
示例3: NetworkDevice
public NetworkDevice(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType, EndPoint endPoint)
{
_AddressFamily = addressFamily;
_SocketType = socketType;
_ProtocolType = protocolType;
_EndPoint = endPoint;
}
示例4: CreateSocket
public static unsafe SafeCloseSocket CreateSocket(SocketInformation socketInformation, out AddressFamily addressFamily, out SocketType socketType, out ProtocolType protocolType)
{
SafeCloseSocket handle;
Interop.Winsock.WSAPROTOCOL_INFO protocolInfo;
fixed (byte* pinnedBuffer = socketInformation.ProtocolInformation)
{
handle = SafeCloseSocket.CreateWSASocket(pinnedBuffer);
protocolInfo = (Interop.Winsock.WSAPROTOCOL_INFO)Marshal.PtrToStructure<Interop.Winsock.WSAPROTOCOL_INFO>((IntPtr)pinnedBuffer);
}
if (handle.IsInvalid)
{
SocketException e = new SocketException();
if (e.SocketErrorCode == SocketError.InvalidArgument)
{
throw new ArgumentException(SR.net_sockets_invalid_socketinformation, "socketInformation");
}
else
{
throw e;
}
}
addressFamily = protocolInfo.iAddressFamily;
socketType = (SocketType)protocolInfo.iSocketType;
protocolType = (ProtocolType)protocolInfo.iProtocol;
return handle;
}
示例5: SocketManager
public SocketManager(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
{
_addressFamily = addressFamily;
_socketType = socketType;
_protocolType = protocolType;
_listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
}
示例6: Client
public Client(IPAddress ip, int port, ProtocolType protocol = ProtocolType.Tcp, string connectionKey = "")
{
initialized = false;
key = System.Text.Encoding.UTF8.GetBytes(connectionKey);
client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, protocol);
Initialize(ip, port);
}
示例7: Socket_internal
private IntPtr Socket_internal(AddressFamily family,
SocketType type,
ProtocolType proto,
out int error)
{
throw new System.NotImplementedException();
}
示例8: IPHeader
public IPHeader(byte[] byBuffer, int nReceived)
{
NetBinaryReader nbr = new NetBinaryReader(byBuffer, 0, nReceived);
Version = nbr.ReadNible();
HeaderLength = nbr.ReadNible();
Precedence = (Precedence)nbr.ReadCustomAmount(3);
LowDelay = nbr.ReadBit();
HighThroughput = nbr.ReadBit();
HighRelibility = nbr.ReadBit();
nbr.SkipPadBits();
TotalLength = nbr.ReadUInt16();
Identification = nbr.ReadUInt16();
nbr.ReadBit();
MayFragment = !nbr.ReadBit();
LastFragment = !nbr.ReadBit();
FragmentOffset = (nbr.ReadPadBits() << 3) + nbr.ReadByte();
TTL = nbr.ReadByte();
Protocol = (ProtocolType)nbr.ReadByte();
HeaderChecksum = IPAddress.NetworkToHostOrder(nbr.ReadInt16());
Source = new IPAddress(nbr.ReadBytes(4));
Destination = new IPAddress(nbr.ReadBytes(4));
}
示例9: P2PServer
public P2PServer(int point,SocketType socketType=SocketType.Dgram,ProtocolType protocolType=ProtocolType.Udp)
{
this.point=point;
this.protocolType =protocolType;
this.socketType=socketType;
}
示例10: SendAndVarReceive
/// <summary>
/// 戻り値をAppVarで取得する通信。
/// </summary>
/// <param name="invoker">呼び出し元。</param>
/// <param name="friendlyConnector">アプリケーションとの接続者。</param>
/// <param name="protocolType">通信タイプ。</param>
/// <param name="operationTypeInfo">操作タイプ情報。</param>
/// <param name="varAddress">変数アドレス。</param>
/// <param name="typeFullName">タイプフルネーム。</param>
/// <param name="operation">操作名称。</param>
/// <param name="arguments">引数。</param>
/// <returns>変数。</returns>
internal static AppVar SendAndVarReceive(object invoker, IFriendlyConnector friendlyConnector, ProtocolType protocolType,
OperationTypeInfo operationTypeInfo, VarAddress varAddress, string typeFullName, string operation, object[] arguments)
{
object value = SendAndValueReceive(invoker, friendlyConnector, protocolType, operationTypeInfo, varAddress, typeFullName, operation, arguments);
VarAddress retHandle = value as VarAddress;
return (retHandle == null) ? (null) : (new AppVar(friendlyConnector, retHandle));
}
示例11: Reset
public void Reset (Socket socket, IPEndPoint ip)
{
this.addressFamily = socket.AddressFamily;
this.socketType = socket.SocketType;
this.protocolTtype = socket.ProtocolType;
this.RemoteEndPoint = ip;
}
示例12: VNESBase
public VNESBase(IPAddress ip, int port, ProtocolType protocol)
{
this.ip = ip;
this.port = port;
this.protocol = protocol;
this.filter = this.BuildFilter();
}
示例13: CreateSocket
public Socket CreateSocket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
{
SetAddressFamily(addressFamily);
SetProtocolType(protocolType);
SetSocketType(socketType);
return new Socket(this.addressFamily, this.socketType, this.protocolType);
}
示例14: CreateConnection
public static async Task<IDisposableConnection<ArraySegment<byte>>> CreateConnection(
EndPoint endpoint,
SocketType socketType = SocketType.Stream,
ProtocolType protocolType = ProtocolType.Tcp)
{
var socket = new Socket(socketType, protocolType);
bool disposeSocket = false;
try
{
using (SocketAwaitableEventArgs args = new SocketAwaitableEventArgs())
{
args.RemoteEndPoint = endpoint;
await socket.ConnectSocketAsync(args);
}
}
catch (Exception)
{
disposeSocket = true;
throw;
}
finally
{
if (disposeSocket)
{
socket.Dispose();
socket = null;
}
}
return socket.ToConnection();
}
示例15: Socket
private Socket(AddressFamily family, SocketType type, ProtocolType proto, IntPtr native)
{
this.family = family;
this.type = type;
this.proto = proto;
this.native = native;
}