- Home /
Networking error CreateSocketOrThreadFailure
I'm working on making a multiplayer game and previously i could host servers and have other mchines join them. Now nobody can connect to a server, upon doing it unity crashes, also upon opening a server you get a error (but unity says the you are hosting a server). Here's the error i get when opening a server.
Could not connect to Master Server: CreateSocketOrThreadFailure
If thats not enough info (it probably isn't) here is my network script.
//UNITY MULTIPLAYER BASE SCRIPT
//V0.1
static var isConnectedToInternet = false;
static var tries = 0;
var stuff : String;
function OnFailedToConnect(error: NetworkConnectionError) {
Debug.Log("Could not connect to server: "+ error);
}
function OnFailedToConnectToMasterServer(error: NetworkConnectionError) {
Debug.Log("Could not connect to Master Server: "+ error);
}
function Update () {
if (Network.player.ipAddress.ToString() != "127.0.0.1")
{
isConnectedToInternet = true;
}
}
function Start() {
Network.TestConnection();
}
static function StartServer (maxPlayers : int, port : int, GameName : String) : void {
Network.InitializeServer(maxPlayers, port, !Network.HavePublicAddress());
MasterServer.RegisterHost("NHDVirtualReality", GameName, "Indev");
Debug.Log("Server " + GameName + " Started On Port:" + port);
}
static function ShouldUseNAT () {
var shouldUseNat;
var testResults = Network.TestConnection();
if (testResults == ConnectionTesterStatus.PublicIPIsConnectable || testResults == ConnectionTesterStatus.Error || testResults == ConnectionTesterStatus.PublicIPNoServerStarted) {
shouldUseNat = false;
}
else {
shouldUseNat = true;
}
return shouldUseNat;
}
static function ConnectToServer (port : int, ip : String) {
Network.Connect("ip", port);
}
static function ConnectToServer (server : HostData) {
Network.Connect(server);
}
static function Disconnect () {
Network.Disconnect();
MasterServer.UnregisterHost();
}
static function NetworkAdd (target : Object, playerPos : Vector3) {
var player : GameObject;
if (Network.peerType != NetworkPeerType.Disconnected){
player = Network.Instantiate(target, playerPos, Quaternion.identity, 0);
}
else
{
LocalAdd(target, playerPos);
}
}
static function LocalAdd (target : Object, playerPos : Vector3) {
var player : GameObject;
player = Instantiate(target, playerPos, Quaternion.identity);
}
static function GetServers () : HostData[] {
MasterServer.RequestHostList("NHDVirtualReality");
var servers : HostData[] = MasterServer.PollHostList();
if (servers == null & tries < 5) {
MasterServer.RequestHostList("NHDVirtualReality");
servers = MasterServer.PollHostList();
tries ++;
if (servers != null) {
tries = 0;
return servers;
}
else if (servers == null) {
GetServers();
}
}
return servers;
}
static function GetServerData (serverData : HostData[], serverNumber : int) {
var lengthOfData = serverData.length;
if (serverNumber <= lengthOfData){
var sendData : HostData;
sendData = serverData[serverNumber];
return sendData;
}
else {
return null;
}
}
static function JoinMainServer () {
availableServers = GetServers();
serverToJoin = GetServerData (availableServers, 0);
ConnectToServer(serverToJoin);
return "Done";
}
The error occurs upon calling the StartServer function. Any ideas?
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Help with Java socket server 1 Answer
uploading file on server and keep getting an error 1 Answer
Why i can't receive 2 messages in a row from my server in Unity? 2 Answers
Server still sending Packets to inactive clients and throwing errors. How can I stop it? 0 Answers