mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-05-10 15:28:18 +02:00
Client: Fixed a bug related to localhost communication
This commit is contained in:
parent
a0a372dd16
commit
2caf390c41
2 changed files with 13 additions and 21 deletions
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2014-2018 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
||||
/* Copyright (C) 2014-2019 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
||||
*
|
||||
* You can redistribute this program and/or modify it under the terms of
|
||||
* the GNU Lesser Public License as published by the Free Software Foundation,
|
||||
|
@ -31,7 +31,6 @@ namespace SMBLibrary.Client
|
|||
private bool m_isConnected;
|
||||
private bool m_isLoggedIn;
|
||||
private Socket m_clientSocket;
|
||||
private IAsyncResult m_currentAsyncResult;
|
||||
private bool m_forceExtendedSecurity;
|
||||
private bool m_unicode;
|
||||
private bool m_largeFiles;
|
||||
|
@ -87,7 +86,7 @@ namespace SMBLibrary.Client
|
|||
|
||||
ConnectionState state = new ConnectionState();
|
||||
NBTConnectionReceiveBuffer buffer = state.ReceiveBuffer;
|
||||
m_currentAsyncResult = m_clientSocket.BeginReceive(buffer.Buffer, buffer.WriteOffset, buffer.AvailableLength, SocketFlags.None, new AsyncCallback(OnClientSocketReceive), state);
|
||||
m_clientSocket.BeginReceive(buffer.Buffer, buffer.WriteOffset, buffer.AvailableLength, SocketFlags.None, new AsyncCallback(OnClientSocketReceive), state);
|
||||
bool supportsDialect = NegotiateDialect(m_forceExtendedSecurity);
|
||||
if (!supportsDialect)
|
||||
{
|
||||
|
@ -358,13 +357,6 @@ namespace SMBLibrary.Client
|
|||
|
||||
private void OnClientSocketReceive(IAsyncResult ar)
|
||||
{
|
||||
if (ar != m_currentAsyncResult)
|
||||
{
|
||||
// We ignore calls for old sockets which we no longer use
|
||||
// See: http://rajputyh.blogspot.co.il/2010/04/solve-exception-message-iasyncresult.html
|
||||
return;
|
||||
}
|
||||
|
||||
ConnectionState state = (ConnectionState)ar.AsyncState;
|
||||
|
||||
if (!m_clientSocket.Connected)
|
||||
|
@ -377,6 +369,10 @@ namespace SMBLibrary.Client
|
|||
{
|
||||
numberOfBytesReceived = m_clientSocket.EndReceive(ar);
|
||||
}
|
||||
catch (ArgumentException) // The IAsyncResult object was not returned from the corresponding synchronous method on this class.
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
Log("[ReceiveCallback] EndReceive ObjectDisposedException");
|
||||
|
@ -400,7 +396,7 @@ namespace SMBLibrary.Client
|
|||
|
||||
try
|
||||
{
|
||||
m_currentAsyncResult = m_clientSocket.BeginReceive(buffer.Buffer, buffer.WriteOffset, buffer.AvailableLength, SocketFlags.None, new AsyncCallback(OnClientSocketReceive), state);
|
||||
m_clientSocket.BeginReceive(buffer.Buffer, buffer.WriteOffset, buffer.AvailableLength, SocketFlags.None, new AsyncCallback(OnClientSocketReceive), state);
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
|
|
|
@ -32,7 +32,6 @@ namespace SMBLibrary.Client
|
|||
private bool m_isConnected;
|
||||
private bool m_isLoggedIn;
|
||||
private Socket m_clientSocket;
|
||||
private IAsyncResult m_currentAsyncResult;
|
||||
|
||||
private object m_incomingQueueLock = new object();
|
||||
private List<SMB2Command> m_incomingQueue = new List<SMB2Command>();
|
||||
|
@ -79,7 +78,7 @@ namespace SMBLibrary.Client
|
|||
|
||||
ConnectionState state = new ConnectionState();
|
||||
NBTConnectionReceiveBuffer buffer = state.ReceiveBuffer;
|
||||
m_currentAsyncResult = m_clientSocket.BeginReceive(buffer.Buffer, buffer.WriteOffset, buffer.AvailableLength, SocketFlags.None, new AsyncCallback(OnClientSocketReceive), state);
|
||||
m_clientSocket.BeginReceive(buffer.Buffer, buffer.WriteOffset, buffer.AvailableLength, SocketFlags.None, new AsyncCallback(OnClientSocketReceive), state);
|
||||
bool supportsDialect = NegotiateDialect();
|
||||
if (!supportsDialect)
|
||||
{
|
||||
|
@ -246,13 +245,6 @@ namespace SMBLibrary.Client
|
|||
|
||||
private void OnClientSocketReceive(IAsyncResult ar)
|
||||
{
|
||||
if (ar != m_currentAsyncResult)
|
||||
{
|
||||
// We ignore calls for old sockets which we no longer use
|
||||
// See: http://rajputyh.blogspot.co.il/2010/04/solve-exception-message-iasyncresult.html
|
||||
return;
|
||||
}
|
||||
|
||||
ConnectionState state = (ConnectionState)ar.AsyncState;
|
||||
|
||||
if (!m_clientSocket.Connected)
|
||||
|
@ -265,6 +257,10 @@ namespace SMBLibrary.Client
|
|||
{
|
||||
numberOfBytesReceived = m_clientSocket.EndReceive(ar);
|
||||
}
|
||||
catch (ArgumentException) // The IAsyncResult object was not returned from the corresponding synchronous method on this class.
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
Log("[ReceiveCallback] EndReceive ObjectDisposedException");
|
||||
|
@ -288,7 +284,7 @@ namespace SMBLibrary.Client
|
|||
|
||||
try
|
||||
{
|
||||
m_currentAsyncResult = m_clientSocket.BeginReceive(buffer.Buffer, buffer.WriteOffset, buffer.AvailableLength, SocketFlags.None, new AsyncCallback(OnClientSocketReceive), state);
|
||||
m_clientSocket.BeginReceive(buffer.Buffer, buffer.WriteOffset, buffer.AvailableLength, SocketFlags.None, new AsyncCallback(OnClientSocketReceive), state);
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue