Does Photon Server supports multiple protocol connections? - unity3d

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.

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

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.

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

Related

Cant we read data from an established port using C# or python?

I used netstat to find which ports are established and I tried to read from an established connection using ip and port. I am getting the following error.
Connection actively refused by the machine
No - you can only create a connection to a listening port. "Established" means there is already a connection between two sockets. You can't add a third socket to an existing connection.
If you want to eavesdrop on the connection, there are ways to do that - on Linux, you can create a SOCK_RAW or AF_PACKET socket to receive all packets. On Windows, you need to install the WinPcap or Npcap driver and use libpcap.
If you are just curious and don't need to intercept the connection from a program, you can also use the open source tool Wireshark to see what data your computer is sending and receiving.

Bound Local Port for SignalR Connection

Is there any way to determine which Local Port was used by the Client (C#) to Establish a connection to a SignalR Hub? I have looked at properties of both the HubCallerContext and HubConnection, but it does not seem to be available.
The short answer the question: yes, using netstat or similar you can look at all the connections your client initiated to the SignalR. There you can identify the TCP source port number.
If for some reason you want to get this from inside the application you can either try to find your way via Get underlying tcp connection from HttpWebRequest/Response
or by following this answer.

C socket: TCP/IP multiclient: Chat and transfer file on the same port

I'm writing a C socket program to chat and transfer file between multi clients. There is a lot of topic about TCP client-server but I didn't find any solution to solve my problem. I would like to ask how we use just one port for both connections.
Here is what I've tried and it works well, but I'm using two separate ports for chatting and sharing:
*Server:
1) create a socket and bind it to port 1234 for chatting
2) create another socket and bind it to port 4321 for sharing file
-> we have two listen sockets waiting for clients to connect.
*Client:
1) Create a socket and connect to port 1234 of server //chatting
2) Create a second socket and connect to port 4321 of server //sharing
--> for each client, we need two socket connect to two ports of the server -> we can chat and share file at the same time.
The problem is it seems not efficient and face up to some problems:
a) Use two ports -> require the server open port forwarding on both
b) If we have multi clients connect to server at the same time, server will detect wrong the chatting and sharing socket of two clients
I also found a suggestion to use a socket and mark flag/header the transmit data then we can separate chatting and sharing data. But if the buffer size of client and server is different, we can't receive full of packet each time to detect the type of receiving packet.
What is the best way to use one port for chat and share concurrently?
and if we integrate more services like stream music, video,etc. How to use multi connection on the same port?
If we use multi connection on the same port how to detect type of connection (chat or share) when a new client is accepted?
Thank you,

send data between two server sockets

I have to make an app using C/PHP sockets on linux that sends data from one socket to other socket, like this.
I have server (server_hosted) hosted somewhere with an IP or domain name. It is running web application.
I have another server (unknown_server) running at my home (unknown IP).
Client send some information through web application hosted in server_hosted to another server running at my home (unknown IP).
I need a way to established a connection between server_hosted and unknown_server.
I was able to make connection between both using TCP socket. I made server_hosted as server listen to certain port says 8080 and unknown_server as client, which make open connection to server_hosted.
The problem comes when I have multiple unknown_server at my home. How can I made connection to same port? How many client can TCP/IP support?
Any ides how to make tunnel or connection between server_hosted and unknown_server.
Is possible to do with curl or socket any better ideas?

capturing TCP packets flow

Problem statement:
Suppose a parent server is hosted on a machine IP: 1.1.1.1 and that server some time communicates with three different servers say A (1.1.1.2), B (1.1.1.3), C (1.1.1.4). Those servers may be database servers or any other servers.
Now from your browser you can send a http request to 1.1.1.1/somePage.htm, as a result some TCP packet will go to the server 1.1.1.1, and 1.1.1.1 can send and receive some TCP packets from A,B,C as well.
Aim is to get the information of all TCP packets from the browser machine, without installing any agent software in any servers.
One solution is we can write a code at the 1.1.1.1 server machine that will filter all the TCP packets with respect to respective IPs. But I don’t want that solution.
Is there any way to solve this issue? Is it possible to introduce new protocol for this? But server codes can’t be modified.
Does "any agent software" includes something like Wireshark? Usually the way to look at all datagrams received is by using a sniffer like Wireshark or you can use tcpdump in Linux servers.
You can also use Netfilter to handle received packets in the server an take certain actions on them.
If all the above is included in what you don't want to do the only alternative I see is to add another server in the middle between the browser and the web server (or between the server and a load balancer if you have a load balancer) that acts only as a router or bridge. In that machine you can inspect and filter TCP segments with all the available tools.