Permalink
Browse files

Merge pull request #4 from mdavid/udp-socket-definition-fix-from-txdv

Udp socket definition fix from txdv
  • Loading branch information...
2 parents 1ec6700 + f16ec86 commit bbc4175dfc8ef91fa324ce2a9f4a1723350e9187 @mdavid committed May 14, 2012
@@ -74,8 +74,7 @@ void RaiseData (byte[] data, int dataLength, IPEndPoint source)
var copy = new byte[dataLength];
Buffer.BlockCopy (data, 0, copy, 0, copy.Length);
RaiseData (new UdpPacket (
- source.Address.ToString (),
- source.Port,
+ source,
new ByteBuffer (copy)));
}
@@ -87,7 +86,7 @@ protected override WriteResult WriteSingleFragment (UdpPacket packet)
len = SocketFunctions.manos_socket_send (Handle.ToInt32 (), packet.Buffer.Bytes,
packet.Buffer.Position, packet.Buffer.Length, out error);
} else {
- ManosIPEndpoint ep = new IPEndPoint (IPAddress.Parse (packet.Address), packet.Port);
+ ManosIPEndpoint ep = packet.IPEndPoint;
len = SocketFunctions.manos_socket_sendto_ip (Handle.ToInt32 (), packet.Buffer.Bytes,
packet.Buffer.Position, packet.Buffer.Length, ref ep, out error);
}
@@ -60,8 +60,9 @@ void ReceiveFrom (IAsyncResult ar)
Buffer.BlockCopy (buffer, 0, newBuffer, 0, length);
var info = new UdpPacket (
- ipremote.Address.ToString (),
- ipremote.Port,
+ new Manos.IO.IPEndPoint (
+ new Manos.IO.IPAddress(ipremote.Address.GetAddressBytes()),
+ ipremote.Port),
new ByteBuffer (newBuffer));
Context.Enqueue (delegate {
@@ -73,7 +74,7 @@ void ReceiveFrom (IAsyncResult ar)
protected override WriteResult WriteSingleFragment (UdpPacket packet)
{
- var ep = new System.Net.IPEndPoint (System.Net.IPAddress.Parse (packet.Address), packet.Port);
+ var ep = new System.Net.IPEndPoint (new System.Net.IPAddress (packet.IPEndPoint.Address.GetAddressBytes()), packet.IPEndPoint.Port);
parent.socket.BeginSendTo (packet.Buffer.Bytes, packet.Buffer.Position, packet.Buffer.Length,
SocketFlags.None, ep, WriteCallback, null);
@@ -19,25 +19,16 @@ public class UdpPacket
/// <param name='buffer'>
/// Buffer received/to be sent.
/// </param>
- public UdpPacket (string address, int port, ByteBuffer buffer)
+ public UdpPacket (IPEndPoint endPoint, ByteBuffer buffer)
{
- this.Address = address;
- this.Port = port;
+ this.IPEndPoint = endPoint;
this.Buffer = buffer;
}
/// <summary>
- /// The IP address in string format of the sender/receiver depending on UdpSocket function
+ /// The IP endpoint of the sender/receiver depending on UdpSocket function
/// </summary>
- public string Address {
- get;
- private set;
- }
-
- /// <summary>
- /// The port of the sender/receiver depending on UdpSocket functino
- /// </summary>
- public int Port {
+ public IPEndPoint IPEndPoint {
get;
private set;
}

0 comments on commit bbc4175

Please sign in to comment.