Basic networking questions


Here’s few questions related to networking:

1- How to define an empty netDatagram.getConnection() within a class ?
for exemple:

class Player(NodePath):
  def __init__(self):''    
    self.sourceOfMessage= ???

Manual explains:
PointerTo< Connection > NetDatagram::get_connection(void) const;
But I don’t know how to use it.

2- Is there some functions already written for pinging and broadcasting or should I write my own ?

3- (related to 2) Is there an event detecting if a connection just dropped or should write a task wich pings all hosts each minute ?

4- when I print a netDatagram I got this:

Is it a secured encrypted information or should I use ssh ?

  1. I don’t understand your question. If you have a netDatagram, you can call netDatagram.getConnection(), and it returns a Connection object. This is the same Connection object that you must have already created earlier to read the netDatagram from in the first place. You use this method when you might have multiple connections sharing the same ConnectionReader; with this method you can tell which connection sent the netDatagram that you just retrieved.

  2. Panda doesn’t provide these.

  3. You can ask your QueuedConnectionManager for a list of the connections that have dropped recently, with resetConnectionAvailable()/getResetConnection().

  4. You are looking at the actual bytes packed in a datagram and delivered to you from the other end. Data is not sent securely. If you need this, you will need to wrap the whole thing in ssl yourself, via some external mechanism (such as sslwrapper).

I believe there are several examples of the use of some of these techniques elsewhere in the forums.


Thanks David for your answers :slight_smile:
Shortly, I’ll search how to use ssl

This is exactly what I’m doing but my server needs to process data between players before answering each of them.
In fact, there is a hold time : a player take a decision and other players needs then to choose their own. Then, server process all avatar’s decisions, random few stuff and answer each host from that spot and only that spot (not all players connected).
Reason why I created a Player class on the server including their getConnection().
Like this, when the server needs to send an information to one player, I just need to send it to player.sourceOfMessage.
Here is why I need to declare a netDatagram.getConnection within a class. If there is an other easier trick, I’ll pick it.

Well an other way of asking might be: how can I declare an empty netDagram.getconnection.
If I want an empty string, I’ll use myString=’’
For a list, that will be myList= []
for a getConnection= ??

Sorry, I still don’t understand. The terms you use are confusing. You refer to a getConnection() as a thing, but that’s the name of a method. Maybe you mean to refer to a Connection object instead, which is the thing returned by getConnection()?

There’s no such thing as an “empty” Connection. A Connection object is created when you have established communications with another host. If you want a placeholder object for when you don’t have communications, use something like None.


I found a solution which looks to be working, I’m passing the netDatagram.getConnection() at the creation of the player like this :

sourceOfMessage= NetDatagram.getConnection()
myIterator = PyDatagramIterator(datagram)
name= myIterator.getString()
player1= Player(name, sourceOfMessage)
class Player(self):
   def __init__(self,name,sourceOfMessage): name
      self.sourceOfMessage= sourceOfMessage

I still don’t know what’s the difference between a NetDatagram and NetDatagram() but anyway, it’s working this way… So, hoping that it will continue working, I can continue with my code…

NetDatagram is the object itself, NetDatagram() is an instance to this object.

Hi all,

I’m still on a journey to write a small server for my game which I thought was running quiet well untill a friend came home and I’ve showed him what I’m doing… We tested the game on two computers and he managed (very easily) to make the server (on my computer) crash.

Well, the error was easy to find. He was on a location when he was supposed to interract with objects and he “stupidly” clicked many times on one of them (when one click was enough) --> the server received then the same request many times (instead of 1) and generate more events than expected… :blush: Hum…!
This little story make me understand that I’m not done yet with this server!

An other point, I completly abounded the idea of securing the client part. Using ssh will secure the information on the network while the risk here is the player himself. Also, the crossing information are not “high classified data”… :slight_smile: The only thing I’m searching to do is to keep my server app running or at least ALIVE

So, what are your suggestions for that ?
What should I start think of and what is the must for a server to keep running ?

What I always want to see is a flowchart. I think OpenOffice has a flowchart editor or its draw tool can accomplish a similar thing.

If you ask someone else for a review of your flowchart, and they find no problem with it, you get a lot of confidence.

You can also enumerate your paths if you have a graph structure, which is exhaustive, but exhausting.

I probably badly asked for advice.
By my previous post, I meant that there is always errors that we forget to handle. The exemple given was an easy one to find by testing but there is many others that are more difficult to figure out.
The player can access the source code which will allow him to cheat and there is nothing to do against that but the concern here is: what’s the best way to detect malicious players and not allow them to make the server crash.

Maybe I’m going too far but the game here is inverted. I’m the bad guy who want to kill the server. How am I going to process ?
I already thought about few ideas :

  • Check repeated advices in comparaison of other players and delete player who generate infinit while loops messages to the server.
  • Separate the information between watchers and players where watchers will not have their output in the game and server ignore their messages.
  • Checking player state between two broadcasting synchro message (which I still don’t know how to implement and might be completly useless…)

Well, I’m here with my ideas… Do you see something else ?

If your information, such as positions hidden by fog of war, or elsewhere in the game, behind a wall, etc., is on my computer, I can get it. That includes requesting certain aspects of the part of the world I’m modeling, except possibly if some dummy excerpts are requested, and branched after they’re observed by me.

And I can share observations with colluders, so that requires requesting the same dummy observations from all, which gives away additional information.

If the alternatives aren’t eliminated they’re slim; otherwise you’ll have to have the state on a trusted server, and release information NTK, need to know.