void Start() {
UdpClient u = new UdpClient();
u.Client.ConnectAsync("127.0.0.1", 9050);
Byte[] sendBytes = Encoding.ASCII.GetBytes("Is anybody there?");
u.SendAsync(sendBytes, sendBytes.Length);
StartNetworking();
}
public async Task StartNetworking()
{
var receivedResults = await u.ReceiveAsync();
Debug.Log(receivedResults.ToString());
StartNetworking();
}
Here is a client UDP script. It’s able to send messages properly but it isn’t able to receive them at all.
Here is my server script, which is able to receive messages just fine.
void Start() {
u = new UdpClient(9050);
StartNetworking();
}
public async Task StartNetworking()
{
var receivedResults = await u.ReceiveAsync();
Byte[] sendBytes = Encoding.ASCII.GetBytes("Send 2 Client");
u.SendAsync(sendBytes, sendBytes.Length, receivedResults.RemoteEndPoint);
StartNetworking();
}
Any help would be greatly appreciated.