| | |
| | | { |
| | | return; |
| | | } |
| | | isInited = true; |
| | | isInited = true;
|
| | |
|
| | | //初始化Socket
|
| | | FindGateWaySocket.Start(); |
| | | |
| | | new System.Threading.Thread(async () => |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | var broadcastIpAddress = new Shared.Net.NetWiFi().BroadcastIpAddress; |
| | | |
| | | var broadcastIpAddress = new Shared.Net.NetWiFi().BroadcastIpAddress;
|
| | |
|
| | | if (Shared.Application.IsWifi)
|
| | | {
|
| | | if (0 < gateWayList.Count)
|
| | |
| | | FindGateWaySocket.BeginSend(new System.Net.IPEndPoint(broadcastIpAddress, 7624), broadBytes); |
| | | } |
| | | } |
| | | catch
|
| | | { |
| | | //关闭Socket,下次发送会自动连接 |
| | | FindGateWaySocket.Stop();
|
| | | } |
| | | catch{} |
| | | System.Threading.Thread.Sleep(500); |
| | | } |
| | | }) |
| | |
| | | var bytes = new byte[1024]; |
| | | |
| | | var len = FindGateWaySocket.busSocket.Receive(bytes, bytes.Length, System.Net.Sockets.SocketFlags.None); |
| | | |
| | | if (bytes[43] == 0xA2) |
| | | { |
| | | //广播回复网关的基本信息处理 |
| | |
| | | }
|
| | | } |
| | | } |
| | | else |
| | | {
|
| | | //调试用
|
| | | if (Shared.Phone.UserCenter.UserCenterResourse.HideOption.WriteSocketReceiveDataToFile == 1)
|
| | | {
|
| | | var data33 = Encoding.UTF8.GetString(bytes).Replace("�)", string.Empty).TrimStart('\0').TrimEnd('\0');
|
| | | Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(3, data33);
|
| | | } |
| | | } |
| | | } |
| | | catch |
| | | { |
| | | //关闭Socket,下次发送会自动连接 |
| | | FindGateWaySocket.Stop(); |
| | | } |
| | | catch{} |
| | | } |
| | | #endregion |
| | | } |
| | |
| | | { |
| | | try |
| | | { |
| | | Start(7624); |
| | | busSocket.BeginSendTo(bytes, 0, bytes.Length, SocketFlags.None, iPEndPoint, new AsyncCallback(asyncEndSend), null); |
| | | if (IsRunning)
|
| | | {
|
| | | busSocket.BeginSendTo(bytes, 0, bytes.Length, SocketFlags.None, iPEndPoint, new AsyncCallback(asyncEndSend), null);
|
| | | } |
| | | |
| | | } |
| | | catch { } |
| | | catch (Exception ex) |
| | | {
|
| | | //调试用
|
| | | if (Shared.Phone.UserCenter.UserCenterResourse.HideOption.WriteSocketReceiveDataToFile == 1)
|
| | | {
|
| | | Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(3, "发送异常(BeginSendTo)\r\n" + ex.Message);
|
| | | }
|
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | int bytesSent = busSocket.EndSendTo(iar); |
| | | } |
| | | catch { } |
| | | catch(Exception ex) |
| | | {
|
| | | //调试用
|
| | | if (Shared.Phone.UserCenter.UserCenterResourse.HideOption.WriteSocketReceiveDataToFile == 1)
|
| | | {
|
| | | Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(3, "异步发送结束异常(asyncEndSend)\r\n" + ex.Message);
|
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |