Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
d7c6fdd6ac | |||
103bd58fef |
Before Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
Before Width: | Height: | Size: 342 KiB |
|
@ -40,12 +40,21 @@ public class Server : MonoBehaviour {
|
|||
disconnectIndex = new List<int>();
|
||||
|
||||
try {
|
||||
server = new TcpListener(IPAddress.Any, Port);
|
||||
IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
|
||||
IPAddress localAddress = IPAddress.Any;
|
||||
foreach(IPAddress ip in hostEntry.AddressList){
|
||||
if(ip.AddressFamily==System.Net.Sockets.AddressFamily.InterNetwork){
|
||||
localAddress = ip;
|
||||
break;
|
||||
}
|
||||
}
|
||||
server = new TcpListener(localAddress, Port);
|
||||
server.Start();
|
||||
|
||||
Startlistening();
|
||||
serverStarted = true;
|
||||
Debug.Log("Server has started on port:" + Port.ToString());
|
||||
Debug.Log("Server has started on IP:" + localAddress.ToString());
|
||||
}
|
||||
catch (Exception e) {
|
||||
Debug.Log("Socket Error " + e.Message);
|
||||
|
@ -274,4 +283,4 @@ public class ServerClient {
|
|||
tcp = clientSocket;
|
||||
ClientObj = new List<GameObject>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|