public bool send_cmd(byte cmd, String str) { #if UNITY_EDITOR #elif UNITY_STANDALONE_WIN byte[] data = packet.create_output_from_string(cmd, str); _conn_sock.send_data(data); #endif return(true); }
bool send_cmd_and_wait_response(byte cmd, String str, ref packet pk, int micro_seconds) { vesal_socket sock = new vesal_socket(); bool result = sock.connect("127.0.0.1", port); if (!result) { vesal_log.vesal_write_log("cant conn"); return(false); } byte[] data = packet.create_output_from_string(cmd, str); sock.send_data(data); long cur = DateTime.Now.Ticks / 10000; bool ret = false; while (true) { System.Threading.Thread.Sleep(1); ArrayList sockList = new ArrayList(); sockList.Add(sock._sock); Socket.Select(sockList, null, null, 1); if (sockList.Count > 0) { try { ret = sock.recv_packet(ref pk); } catch { vesal_log.vesal_write_log("recv failed!!!"); return(false); } } if (ret) { vesal_log.vesal_write_log("get response"); break; } long cur2 = DateTime.Now.Ticks / 10000; if (cur2 >= cur + micro_seconds) { vesal_log.vesal_write_log("time out"); break; } } sock.close(); return(ret); }
public bool send_cmd(byte cmd, String str) { byte[] data = packet.create_output_from_string(cmd, str); _conn_sock.send_data(data); return(true); }