soundvision/UnityProject/Assets/Scripts/PdConnection/PdSender.cs
Chikashi Miyama d00d95859f refer #60
2019-10-05 14:18:52 +02:00

32 lines
No EOL
653 B
C#

using System;
using System.Net;
using System.Net.Sockets;
namespace cylvester
{
public interface IPdSender : IDisposable
{
void Send(byte[] bytes);
}
public class PdSender : IPdSender
{
private Socket socket_;
public PdSender(string ip, int port)
{
socket_ = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
socket_.Connect(IPAddress.Parse(ip), port);
}
public void Send(byte[] bytes)
{
socket_.Send(bytes);
}
public void Dispose()
{
socket_.Close();
}
}
}