using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; using System.Runtime.InteropServices; namespace ConsoleApplication22 { class Program { [DllImport("Ws2_32.dll")] public static extern uint inet_addr(String addr); [DllImport("Iphlpapi.dll")] public static extern int SendARP(uint dest, Int32 host, ref Int64 mac, ref Int32 length); static void Main(string[] args) { string[] Signal= new string[5] { "59", "50", "23", "591", "720"}; string[] Lock = new string[3] { "0/r/n", "1/r/n", "2/r/n" }; string[] Status = new string[4] { "Stopped/r/n", "Init/r/n", "Ready/r/n", "eee/r/n" }; Random ra = new Random(); int tmp1 = ra.Next(); int tmp2 = ra.Next(); int tmp3 = ra.Next(); //文字コードを指定する System.Text.Encoding enc = System.Text.Encoding.UTF8; string host = "192.168.6.125"; int port = 14; System.Net.IPAddress ipAdd = System.Net.Dns.Resolve(host).AddressList[0]; System.Net.Sockets.TcpListener listener = new System.Net.Sockets.TcpListener(ipAdd, port); listener.Start(); Console.WriteLine("Port{0}のListenを開始しました。", port); //接続要求があったら受け入れる System.Net.Sockets.TcpClient tcp = listener.AcceptTcpClient(); Console.WriteLine("クライアントが接続しました。"); //NetworkStreamを取得 System.Net.Sockets.NetworkStream ns = tcp.GetStream();