本文整理汇总了C#中Socket.IncreaseSequenceNumber方法的典型用法代码示例。如果您正苦于以下问题:C# Socket.IncreaseSequenceNumber方法的具体用法?C# Socket.IncreaseSequenceNumber怎么用?C# Socket.IncreaseSequenceNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Socket
的用法示例。
在下文中一共展示了Socket.IncreaseSequenceNumber方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendBind
public static void SendBind(Socket destination, Pipe pipe, bool increaseSequenceNumber)
{
if(increaseSequenceNumber)
destination.IncreaseSequenceNumber();
var command = new BindCommand(destination, pipe);
SendCommand(command);
}
示例2: ConnectEndpoint
internal static Pipe ConnectEndpoint(Socket connectSocket, string address)
{
lock (s_endpointsSync)
{
Socket boundSocket;
int connectHighWatermark = connectSocket.Options.SendHighWatermark;
int bindHighWatermark = connectSocket.Options.ReceiveHighwatermark;
if (s_endpoints.TryGetValue(address, out boundSocket))
{
// Increment the command sequence number of the peer so that it won't
// get deallocated until "bind" command is issued by the caller.
// The subsequent 'bind' has to be called with inc_seqnum parameter
// set to false, so that the seqnum isn't incremented twice.
boundSocket.IncreaseSequenceNumber();
if (connectHighWatermark != 0 && boundSocket.Options.ReceiveHighwatermark != 0)
connectHighWatermark += boundSocket.Options.ReceiveHighwatermark;
if (bindHighWatermark != 0 && boundSocket.Options.SendHighWatermark != 0)
bindHighWatermark += boundSocket.Options.SendHighWatermark;
}
Pipe connectPipe;
Pipe bindPipe;
Pipe.CreatePair(connectSocket, boundSocket ?? connectSocket,
bindHighWatermark, connectHighWatermark, out connectPipe, out bindPipe);
if (boundSocket == null)
{
// The peer doesn't exist yet so we don't know whether
// to send the identity message or not. To resolve this,
// we always send our identity and drop it later if
// the peer doesn't expect it.
Frame identity = new Frame(0);
identity.Identity = true;
connectPipe.TryWrite(ref identity);
connectPipe.Flush();
connectSocket.IncreaseSequenceNumber();
AddPendingConnection(connectSocket, address, connectPipe, bindPipe);
}
else
{
// If required, send the identity of the local socket to the peer.
if (boundSocket.Options.ReceiveIdentity)
{
Frame identity = new Frame(0);
identity.Identity = true;
connectPipe.TryWrite(ref identity);
connectPipe.Flush();
}
// If required, send the identity of the peer to the local socket.
if (connectSocket.Options.ReceiveIdentity)
{
Frame identity = new Frame(0);
identity.Identity = true;
bindPipe.TryWrite(ref identity);
bindPipe.Flush();
}
// Attach remote end of the pipe to the peer socket. Note that peer's
// sequence nubmer was incremented in find endpoint function. We don't need it
// increased here.
CommandDispatcher.SendBind(boundSocket, bindPipe, false);
}
return connectPipe;
}
}
示例3: ConnectInprocSockets
private static void ConnectInprocSockets(Socket boundSocket, PendingConnection connection)
{
boundSocket.IncreaseSequenceNumber();
connection.BindPipe.SlotId = boundSocket.SlotId;
// If bound socket doesn't receive identity we need to read from the pipe as we already
// insert the message while creating the pipe pair
if (!boundSocket.Options.ReceiveIdentity)
{
Frame frame;
connection.BindPipe.TryRead(out frame);
frame.Close();
}
int inHighWatermark = 0;
int outHighWatermark = 0;
if (boundSocket.Options.SendHighWatermark != 0 &&
connection.Socket.Options.ReceiveHighwatermark != 0)
inHighWatermark =
boundSocket.Options.SendHighWatermark + connection.Socket.Options.ReceiveHighwatermark;
if (boundSocket.Options.ReceiveHighwatermark != 0 &&
connection.Socket.Options.SendHighWatermark != 0)
outHighWatermark =
boundSocket.Options.ReceiveHighwatermark + connection.Socket.Options.SendHighWatermark;
// Set the highwatermarks now as before the bound highwater marks was missing
connection.ConnectPipe.SetHighWatermarks(inHighWatermark,outHighWatermark);
connection.BindPipe.SetHighWatermarks(outHighWatermark, inHighWatermark);
BindCommand bindCommand = new BindCommand(boundSocket, connection.BindPipe);
boundSocket.Process(bindCommand);
CommandDispatcher.SendInprocConnected(connection.Socket);
if (connection.Socket.Options.ReceiveIdentity)
{
Frame identity = new Frame();
identity.Identity = true;
connection.BindPipe.TryWrite(ref identity);
connection.BindPipe.Flush();
}
}