How to find out if a client is connected to a pymodbus tcp server - modbus

I have a pymodbus server running and I'd like to know if a client is connected to it that it is serving. Is there any way to do that? I can't see an obvious way.
I'm using the synchronous server:
pymodbus.server.sync.ModbusTcpServer

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.

Is it possible to create a proxy server for any application?

I've been trying to create a proxy server to analyze TCP packages sent between my computer and a game server.
Now I know that you can do this kind of stuff with Wireshark, but I want to understand the logic of it and how the connections are made.
My main question is that I don't know where to start from. I have the server IP and port from Process Explorer and have the basic socket programming knowledge in python, but as I said, I don't know what to code.
Am I supposed to write a socket that hijacks the incoming TCP connection and forward it to my localhost? but then how would my client send data to server?
As you can see, I'm a bit lost, and I would be very happy if someone could put me in a correct path (what should I research?).
Thank you in advance.
I think there is a useful tools can help you: iptables and netfilter. Using this, you can hijacks the incoming TCP connection and forward it to your localhost easily.

Can Kurento run as a WebSocket client?

I understand that Kurento Server is called this way for a reason, but can it be configured (or hacked) to run as a client in terms of the Kurento Protocol?
According to the Kurento 6.6.1 documentation:
Previous to issuing commands, the Kurento Client requires establishing
a WebSocket connection with Kurento Media Server to the URL:
ws://hostname:port/kurento
But since we would like to run our Kurento Server behind NAT that doesn't have a dedicated IP address and doesn't allow DDNS and port forwarding, it would be really nice if Kurento could connect to our signaling server (WebSocket-based) and permanently sustain that connection. When web-based client connects to that signaling server, a connection would be negotiated between the WebRTC server (Kurento) and the client (browser) via signaling. – Well, that's our hope, at least, since RTSP connection to our camera also cannot be established from the Internet.
See the diagram of what we are trying to achieve:
Thanks.

Does Photon Server supports multiple protocol connections?

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

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?