Game Development Community

Client connection issues with a simple static "connect" button

by Corey · in Torque Game Engine · 06/11/2007 (6:16 pm) · 2 replies

It's kind of embarrassing, but I can't get a simple "connect" button on the main menu to work. All I want it to do is that when it's clicked, it connects the client to a server predefined in code or script. I have pretty much completely reorganized the folder structure of my Torque project, so don't assume the presence of anything - I could easily have missed something in the common code or anywhere else when copying everything over.

What I do have so far is that a copy of serverConnection.cs from starter.fps is there and is being compiled. The button itself calls a function called LaunchGame() which is defined to do the following:
(the if-statement there is to allow for a sort of singleplayer dev-mode I have set up. That DOES work)
function LaunchGame()
{
  %conn = new GameConnection(ServerConnection);
  %conn.SetConnectArgs($pref::Player::Name);
  %conn.SetJoinPassword("none");
  if($dir $= "creator")
    %conn.ConnectLocal();
  else
    %conn.Connect("IP:192.168.0.157:28000");
}

The problem is that when I click the connect button, it enters this function and echoes "Sending Connection Request Challenge" about four or five times, then displays a "timed-out" error. The server NEVER displays any signs of ever seeing this request. If I try to connect to this very same server using starter.fps, I CAN see it when I query LAN and I CAN connect to it (of course, I'm also immediately rejected for not having the correct mod and all, but at least I notice that the server does recognize the incoming connection).

I have read and reread the networking chapter of 3D Game Programming All In One and nothing jumped out at me, so any suggestions are greatly appreciated.

#1
06/11/2007 (6:22 pm)
Try adding setNetPort(0); on the client and setNetPort(28000); allowConnections(true); on the server (although it sounds like you may already have the server configured correctly).

That was the piece I was missing the other day when I was doing manual connections and kept getting the behavior you are describing.
#2
06/11/2007 (8:47 pm)
Goodness, SetNetPort(0) is exactly what was missing. Many, many thanks! Being new to this and all, I wasn't quite sure what I was looking for, so I was looking in everything that dealt directly with connecting. I didn't even think to check client initialization. SetNetPort and AllowConnections were both already covered in copied common code, though, so I didn't have to include those.

Thanks, again.