本文整理汇总了C#中HttpConnection.BeginReadRequest方法的典型用法代码示例。如果您正苦于以下问题:C# HttpConnection.BeginReadRequest方法的具体用法?C# HttpConnection.BeginReadRequest怎么用?C# HttpConnection.BeginReadRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpConnection
的用法示例。
在下文中一共展示了HttpConnection.BeginReadRequest方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: processAccepted
private static void processAccepted (Socket socket, EndPointListener listener)
{
HttpConnection conn = null;
try {
conn = new HttpConnection (socket, listener);
lock (listener._unregisteredSync)
listener._unregistered[conn] = conn;
conn.BeginReadRequest ();
}
catch {
if (conn != null) {
conn.Close (true);
return;
}
socket.Close ();
}
}
示例2: OnAccept
static void OnAccept (IAsyncResult ares)
{
EndPointListener epl = (EndPointListener) ares.AsyncState;
Socket accepted = null;
try {
accepted = epl.sock.EndAccept (ares);
} catch {
// Anything to do here?
} finally {
try {
epl.sock.BeginAccept (OnAccept, epl);
} catch {
if (accepted != null) {
try {
accepted.Close ();
} catch {}
accepted = null;
}
}
}
if (accepted == null)
return;
if (epl.secure && (epl.key == null)) {
accepted.Close ();
return;
}
HttpConnection conn = new HttpConnection (accepted, epl);
conn.BeginReadRequest ();
}
示例3: OnAccept
static void OnAccept (object sender, EventArgs e)
{
SocketAsyncEventArgs args = (SocketAsyncEventArgs) e;
EndPointListener epl = (EndPointListener) args.UserToken;
Socket accepted = null;
if (args.SocketError == SocketError.Success) {
accepted = args.AcceptSocket;
args.AcceptSocket = null;
}
try {
if (epl.sock != null)
epl.sock.AcceptAsync (args);
} catch {
if (accepted != null) {
try {
accepted.Close ();
} catch {}
accepted = null;
}
}
if (accepted == null)
return;
if (epl.secure && (epl.cert == null || epl.key == null)) {
accepted.Close ();
return;
}
HttpConnection conn = new HttpConnection (accepted, epl, epl.secure, epl.cert, epl.key);
lock (epl.unregistered) {
epl.unregistered [conn] = conn;
}
conn.BeginReadRequest ();
}
示例4: onAccept
private static void onAccept (object sender, EventArgs e)
{
var args = (SocketAsyncEventArgs) e;
var listener = (EndPointListener) args.UserToken;
Socket accepted = null;
if (args.SocketError == SocketError.Success) {
accepted = args.AcceptSocket;
args.AcceptSocket = null;
}
try {
listener._socket.AcceptAsync (args);
}
catch {
if (accepted != null)
accepted.Close ();
return;
}
if (accepted == null)
return;
HttpConnection conn = null;
try {
conn = new HttpConnection (accepted, listener);
lock (((ICollection) listener._unregistered).SyncRoot)
listener._unregistered [conn] = conn;
conn.BeginReadRequest ();
}
catch {
if (conn != null) {
conn.Close (true);
return;
}
accepted.Close ();
}
}
示例5: ProcessAccept
private void ProcessAccept(Socket accepted)
{
try
{
var listener = this;
if (listener.secure && listener.cert == null)
{
accepted.Close();
return;
}
var connectionId = Guid.NewGuid().ToString("N");
HttpConnection conn = new HttpConnection(_logger, accepted, listener, listener.secure, listener.cert, connectionId);
//_logger.Debug("Adding unregistered connection to {0}. Id: {1}", accepted.RemoteEndPoint, connectionId);
lock (listener.unregistered)
{
listener.unregistered[conn] = conn;
}
conn.BeginReadRequest();
}
catch (Exception ex)
{
_logger.ErrorException("Error in ProcessAccept", ex);
}
}
示例6: ProcessAccept
private static void ProcessAccept(SocketAsyncEventArgs args)
{
Socket accepted = null;
if (args.SocketError == SocketError.Success)
accepted = args.AcceptSocket;
var epl = (EndPointListener) args.UserToken;
Accept(epl._sock, args, ref accepted);
if (accepted == null)
return;
if (epl._secure && epl._cert == null)
{
accepted.Dispose();
return;
}
var conn = new HttpConnection(accepted, epl, epl._secure, epl._cert);
lock (epl._unregistered)
{
epl._unregistered[conn] = conn;
}
conn.BeginReadRequest();
}