DnsAndConnect









How do I use Dns And Connect
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: SocketUdp.cs Copy
39         public override bool Connect()
40         {
41             lock (this.syncer)
42             {
43                 bool baseOk = base.Connect();
44                 if (!baseOk)
45                 {
46                     return false;
47                 }
48
49                 this.State = PhotonSocketState.Connecting;
50
51                 Thread dns = new Thread(this.DnsAndConnect);
52                 dns.Name = "photon dns thread";
53                 dns.IsBackground = true;
54                 dns.Start();
55
56                 return true;
57             }
58         }
File name: SocketUdp.cs Copy
119         internal void DnsAndConnect()
120         {
121             try
122             {
123                 lock (this.syncer)
124                 {
125                     this.sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
126
127                     IPAddress ep = IPhotonSocket.GetIpAddress(this.ServerAddress);
128                     this.sock.Connect(ep, this.ServerPort);
129
130                     this.State = PhotonSocketState.Connected;
131                 }
132             }
133             catch (SecurityException se)
134             {
135                 if (this.ReportDebugOfLevel(DebugLevel.ERROR))
136                 {
137                     this.Listener.DebugReturn(DebugLevel.ERROR, "Connect() failed: " + se.ToString());
138                 }
139
140                 this.HandleException(StatusCode.SecurityExceptionOnConnect);
141                 return;
142             }
143             catch (Exception se)
144             {
145                 if (this.ReportDebugOfLevel(DebugLevel.ERROR))
146                 {
147                     this.Listener.DebugReturn(DebugLevel.ERROR, "Connect() failed: " + se.ToString());
148                 }
149
150                 this.HandleException(StatusCode.ExceptionOnConnect);
151                 return;
152             }
153
154             Thread run = new Thread(new ThreadStart(ReceiveLoop));
155             run.Name = "photon receive thread";
156             run.IsBackground = true;
157             run.Start();
158         }

DnsAndConnect 158 lượt xem

Gõ tìm kiếm nhanh...