Я использую этот класс для получения данных с платы Arduino со щитом rnet. Он застрял в строке "byte [] receiveBytes = clientReturn.Receive (ref receiveEndPoint);"
public string IP_Connection(string IP_Address)
{
//Port and IP Data for Socket Client
var IP = IPAddress.Parse(IP_Address);
int port = 8888;
var udpClient = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
var sendEndPoint = new IPEndPoint(IP, port);
var receiveEndPoint = new IPEndPoint(IP, port);
var clientReturn = new UdpClient(port);
//int.TryParse(inputVal, out inputInt);
int.TryParse("1", out int inputInt);
// Sends a message to the host to which you have connected.
byte[] sendBytes = Encoding.ASCII.GetBytes(inputInt.ToString());
udpClient.SendTo(sendBytes, sendEndPoint);
string returnData = string.Empty;
// Blocks until a message returns on this socket from a remote host.
byte[] receiveBytes = clientReturn.Receive(ref receiveEndPoint);
returnData = Encoding.ASCII.GetString(receiveBytes);
udpClient.Close();
clientReturn.Close();
return returnData;
}