Does Photon Server supports multiple protocol connections?

1.8k views Asked by At

I need to connect Unity3D client to Photon Server using both UDP and TCP connections. Is it possible? Where can I read about it? P.S. I want to use TCP to send large amount of data.

3

There are 3 answers

0
archgl On BEST ANSWER

Photon server supports multiple protocols simultaneusly. If you downloaded the server sdk look for the PhotonServer.config:

It contains entries like this

<UDPListeners>
    <UDPListener
        IPAddress="0.0.0.0"
        Port="5055">
    </UDPListener>
</UDPListeners>

and

<TCPListeners>
    <TCPListener
        IPAddress="0.0.0.0"
        Port="4530"
        PolicyFile="Policy\assets\socket-policy.xml"
        InactivityTimeout="10000"
        >
    </TCPListener>
</TCPListeners>

Your clients can connect per udp or tcp and interact with each other no mater what protocol thy have chosen.

For the full set of configuration options you can look here: http://doc.exitgames.com/en/onpremise/current/reference/server-config-settings

When a client connects you can query in your server side application how the client connected like this:

public class YourApplication : ApplicationBase
{

    if (initRequest.LocalPort == 5055)
    {
    //
    }

    if (initRequest.PhotonPeer.GetListenerType() == ListenerType.TCPListener)
    {
    //
}

Note: UDPListener in the config are represented as ListenerType.ENetListener in code.

You can find the server sdk documentation in the downloaded {sdk}\doc\Photon.SocketServer.chm or online here http://doc-api.exitgames.com/en/onpremise/current/server/doc/annotated.html

4
Joey Quinto On

Simple answer: No. A photon server cannot have more than 1 type of connection. However, there is a way to do this depending on your definition of a 'server.' For the basis of this explanation, lets call a server the object instance running on a machine. The machine the server is running on, we'll call the machine. You can have multiple servers running from a single machine where they can have different types of connections. For instance, you could have the unity client connect to the physics server using a UDP connection and connect the client to whatever else you needed using a TCP connection.

0
Pham Lai On

Photon server handle connect object called Peerbase. Each peer is each client connection. In client peer connection you only choose protocol is UDP or TCP. Solution is create two peers, one is UDP and one is TCP but hard to handle what UDP and TCP peer is in one client to find player info and send data