Base server code attribute error.

Using the code example in the manual on networking and datagrams as a starting point I have an issue when I try and start the server example.

Please keep in mind this is the very base of the server and the code is nearly identical to what is givin in the manual at this point as this is simply a starting point for me.

Here is the server code I am starting with:

# -- Darkrift Server

import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.distributed.PyDatagram import PyDatagram
from direct.distributed.PyDatagramIterator import PyDatagramIterator
from direct.task import Task
from import Actor

#--Instantate connection classes
cManager = QueuedConnectionManager()
cListener = QueuedConnectionListener(cManager, 0) # <--Changed these to cManager from self.cManager
cReader = QueuedConnectionReader(cManager, 0)
cWriter = ConnectionWriter(cManager, 0)

#--keep track of connections in the array by callback later but for now store them in an array

#--tcp/ip connection port

#--Backlog sets the max connection attempts we ignore

tcpSocket = cManager.OpenTCPServerRendezvous(port_address, backlog)

#--add some polling tasks to do connection polling
taskMgr.add(tskListenerPolling, "Poll the connection listener", -39)
taskMgr.add(tskReaderPolling, "poll the connection reader", -40)

#--Handle incomming connections and hand them off to QueuedConnectionManager
def tskListenerPolling(taskdata):
    if cListener.newConnectionAvailible():
        rendezvous - PointerToConnection()
        netAddress = NetAddress()
        newConnection = PointerToCOnnection()

        if cListener.getNewConnection(rendezvous,netAddress,newConnection):
            newConnection = newConnection.p()
            #--remember new connection
            #--Start reading the connection
    return Task.cont

#--QueuedConnectionManager starts processing incomming packets here
def tskReaderPolling(taskdata):
    if cReader.dataAvailable():
        datagram=NetDatagram()  # <--Catch incomming data here
        if cReader.getData(datagram):
            darkriftProcessDataFunction(datagram) # <--changed process name my need replaced with myProcessDataFunction(datagram)
    return Task.cont

#--Broadcast a message to all clients connected to the server
for aClient in activeConnections:
     cWriter.send(darkriftPyDatagram, aClient)

# --Terminate connection when we are finished with the client
for aClient in activeConnections:

#--Close the listener down

when I try running this i get this error:

DirectStart: Starting the game.
Known pipe types:
(all display modules loaded.)
Traceback (most recent call last):
  File "", line 26, in <module>
    tcpSocket = cManager.OpenTCPServerRendezvous(port_address, backlog)
AttributeError: 'libpanda.QueuedConnectionManager' object has no attribute 'Open

any pointers as to how to fix this ?

Python is case-sensitive. The method name is “openTCPServerRendezvous”, not “OpenTCPServerRendezvous”.


DOh, nice catch lol

now i dont know if this is indentation related or its not importing the imports but here is the next error:

DirectStart: Starting the game.
Known pipe types:
(all display modules loaded.)
Traceback (most recent call last):
  File "", line 30, in <module>
    taskMgr.add(tskListenerPolling, "Poll the connection listener", -39)
NameError: name 'tskListenerPolling' is not defined

EDIT:: Disregard this error please, got ahead of myself again with asking for help. moved the taskMgr code to the bottom of the file and it fixed it. so we are all good again for now :blush: