###環境
VirtualBOX 5.0.8 r103449
Vagrant 1.7.4
ホストOS:OS X Yosemite
ゲストOS:Ubuntu 14.04.3 LTS (64bit)
Unity 5.0.1f1 Personal
###実現したいこと
ホストOSで起動しているUnityからゲストOSへUDP通信をしたいです.
(TCP通信のやり方もおしえてくださるとありがたいです.)
vagrant sshでは正常に接続できています.
###やったこと
- UnityのUDP通信プログラム
UDPClient.cs
1using UnityEngine; 2using System.Net.Sockets; 3using System.Text; 4using System.Collections; 5 6public class UDPClient : MonoBehaviour 7{ 8 // broadcast address 9 public string host = "127.0.0.255"; 10 public int port = 3333; 11 private UdpClient client; 12 13 public Vector3 position; 14 15 void Start () 16 { 17 client = new UdpClient(); 18 client.Connect(host, port); 19 } 20 21 void Update () 22 { 23 } 24 25 void OnGUI() 26 { 27 position = Input.mousePosition; 28 position.z = 10; 29 30 byte[] dgram = Encoding.UTF8.GetBytes(position.ToString()); 31 client.Send(dgram, dgram.Length); 32 } 33 34 void OnApplicationQuit() 35 { 36 client.Close(); 37 } 38}
- Vagrantfileに以下のコードを追加
Vagrantfile
1config.vm.network :forwarded_port, guest: 3333, host: 3333, protocol: "udp"
- VirtualBOXのネットワーク設定にて割り当てをNATに,ポートフォワーディングを以下の通りに設定
プロトコル:UDP,ホストポート:3333,ゲストポート:3333(ポートは33333なども試したがダメ)
###発生している問題
sudo tcpdump port 3333
を実行して確認したところ,ホストOSでは正常に受信できているがゲストOSで受信できていない.
ご協力よろしくお願いします.
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/05/02 05:41