i am trying to write a simple extension in chrome which sends data to a TCP socket server in python.
Unfortunately, extensions cannot use sockets library in chrome.
is there any simple way to communicate with a TCP socket server in python?
Alternatively, is there any way to communicate with python at all?
I think Native Messaging is what you want.
You can find a example code snippet in the Example section of this page.
It uses native messaging to communicate with a Python script.
Related
I'm getting bus error when attempt to write to unix-socket from my client application, so I wanted to debug my connection and communicate through this socket by writing some basic script commands directly from command line bash/python for debugging my connection.
Seems like simple echoing operation is not supported on the socket, Perhaps there's a simple python package to communicate with the socket ?
I'm creating a Python socket server that is supposed to handle requests from a frontend JavaScript. The Python backend needs to be simultaneously connected to another socket server to download real time crypto prices. How would I go about doing that?
I've tried many things, but I'm not able to get both the server and client functionality on my Python working.
I am working on Jasmin SMS gateway and I want to use its CLI module using my python script. It serves this module as telnet. I am not sure ho to send and receive commands from telnet. I have tried telnetlib but I do not know how to use it properly. Jamsin SMS Gateway can be found here:
https://jasmin.readthedocs.io/en/latest/management/jcli/index.html#architecture
I found pexpect library that works great with telnet and ssh clients. I can perform all the tasks of Jamsin's CLI module using my scripts.
There is also a web interface available written in Django and work perfectly with jasmin using pexpect. Its called JasminWebPanel.
I have used Python external package, websocket-client to connect to a RESTful service that sends events.
from websocket import create_connection
ws = create_connection("wss://machine:port/servicename/subscribe")
for event in ws:
print event
...getting events printed
I wonder whether the same functionality can be implemented using the core Python 2.7 or Python 3.5, without installing the external websocket-client package or any other 3rd party Python package.
I have searched the Internet and those examples of code using Python socket module I've seen, refer to connections via http or tcp whereas I need to establish connection via wss.
Very late, but for anyone who might stumble here...Web Sockets protocol is built on TCP so it is expected that implementations of the protocol establish connections via TCP. Also, Web Socket's opening handshake is done following HTTP. This would also explain why Alex saw HTTP connections. If you want to see how to implement one from scratch, install web socket modules (autobahn, which in turn would lead to installing and reading Twisted and asyncio modules, or wampy) and dive into the code. Would recommend reading the Web Sockets protocol specifications at https://www.rfc-editor.org/rfc/rfc6455 before tackling the modules.
I am new to Python - and work on Slackware Linux with Python 3.4.3. I prefer simple no-dependency solutions within one single python script.
I am building a demonized server program (A) which I need to access through both a regular shell CLI and GUIs in my web browser: it serves various files, uses a corresponding database and updates a firefox tab through python's WEBBROWSER function. Currently, I access process (A) via the CLI or a threaded network socket. This all started to work in a localhost scenario with all processes running on one machine.
Now, it turns out that the WebSocket protocol would render my setup dramatically simpler and cut short on traditional flow protocols using Apache and complex frameworks as middlemen.
1st central question: How do I access daemon (A) with websockets from the CLI? I thought about firing up a non-daemon version of my server program, now called (B), and send a program call to its (A) counterpart via the WebSocket HTTP protocol. This would make process (B) a websocket CLIENT, and process (A) a websocket SERVER. Is such a communication at all possible today?
2nd question: Which is the best suited template solution for this scenario - that works with python 3.4.3 ?! I started to play with Pithikos' very sleek python-websocket-server template (see https://github.com/Pithikos/python-websocket-server) but I am unable to use it as CLIENT (initiating the network call) to call its SERVER equivalent (receiving the call while residing in a daemonized process).
Problem 'solved': I gave up on the zero-dependency zero-library idea :
pip install websockets
https://websockets.readthedocs.io
It works like a charm. The WebSocket server sits in the daemon process and receives and processes WebSocket client calls that come from the CLI processes and from the HTML GUIs.