mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-08-11 18:09:19 +02:00
Add missing usings
This commit is contained in:
parent
0b98e1f754
commit
513566a45f
3 changed files with 38 additions and 25 deletions
|
@ -8,6 +8,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
using System.Threading;
|
||||||
using SMBLibrary.NetBios;
|
using SMBLibrary.NetBios;
|
||||||
|
|
||||||
namespace SMBLibrary.Client
|
namespace SMBLibrary.Client
|
||||||
|
@ -43,14 +44,20 @@ namespace SMBLibrary.Client
|
||||||
|
|
||||||
private NodeStatusResponse SendNodeStatusRequest(NodeStatusRequest request)
|
private NodeStatusResponse SendNodeStatusRequest(NodeStatusRequest request)
|
||||||
{
|
{
|
||||||
UdpClient client = new UdpClient();
|
using (UdpClient client = new UdpClient())
|
||||||
|
{
|
||||||
IPEndPoint serverEndPoint = new IPEndPoint(m_serverAddress, NetBiosNameServicePort);
|
IPEndPoint serverEndPoint = new IPEndPoint(m_serverAddress, NetBiosNameServicePort);
|
||||||
client.Connect(serverEndPoint);
|
client.Connect(serverEndPoint);
|
||||||
|
|
||||||
byte[] requestBytes = request.GetBytes();
|
byte[] requestBytes = request.GetBytes();
|
||||||
client.Send(requestBytes, requestBytes.Length);
|
client.Send(requestBytes, requestBytes.Length);
|
||||||
byte[] responseBytes = client.Receive(ref serverEndPoint);
|
Thread.Sleep(100);
|
||||||
|
if (client.Available > 0)
|
||||||
|
{
|
||||||
|
var responseBytes = client.Receive(ref serverEndPoint);
|
||||||
return new NodeStatusResponse(responseBytes, 0);
|
return new NodeStatusResponse(responseBytes, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return new NodeStatusResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,12 @@ namespace SMBLibrary.NetBios
|
||||||
|
|
||||||
public byte[] GetBytes()
|
public byte[] GetBytes()
|
||||||
{
|
{
|
||||||
MemoryStream stream = new MemoryStream();
|
using (MemoryStream stream = new MemoryStream())
|
||||||
|
{
|
||||||
Header.WriteBytes(stream);
|
Header.WriteBytes(stream);
|
||||||
Question.WriteBytes(stream);
|
Question.WriteBytes(stream);
|
||||||
return stream.ToArray();
|
return stream.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,15 +54,18 @@ namespace SMBLibrary.NetBios
|
||||||
{
|
{
|
||||||
Resource.Data = GetData();
|
Resource.Data = GetData();
|
||||||
|
|
||||||
MemoryStream stream = new MemoryStream();
|
using (MemoryStream stream = new MemoryStream())
|
||||||
|
{
|
||||||
Header.WriteBytes(stream);
|
Header.WriteBytes(stream);
|
||||||
Resource.WriteBytes(stream);
|
Resource.WriteBytes(stream);
|
||||||
return stream.ToArray();
|
return stream.ToArray();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private byte[] GetData()
|
private byte[] GetData()
|
||||||
{
|
{
|
||||||
MemoryStream stream = new MemoryStream();
|
using (MemoryStream stream = new MemoryStream())
|
||||||
|
{
|
||||||
stream.WriteByte((byte)Names.Count);
|
stream.WriteByte((byte)Names.Count);
|
||||||
foreach (KeyValuePair<string, NameFlags> entry in Names)
|
foreach (KeyValuePair<string, NameFlags> entry in Names)
|
||||||
{
|
{
|
||||||
|
@ -75,4 +78,5 @@ namespace SMBLibrary.NetBios
|
||||||
return stream.ToArray();
|
return stream.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue