Using the quickfix python along with twisted - python

I have used quickfix in c++. I am trying to use the python version.
Documentation seems a little sparse, so I was hoping to get some information regarding the same.
I have an emulator, that assembles a message in various protocols (some fix/ some non fix).
opens a tcp connection to a server and sends these messages over.
I am considering assembling the fix message using quickfix.
I don't want to use the client portion of quickfix, just the part which assembles a fix message.
Can this be done? ie: does the api support getting the raw fix(which can then be sent over tcp connection) from Message format.
Thanks and Regards.

Use the message.ToString() function to serialize the message.

Related

Python : Clear the buffer in Twisted Transport write

I am developing a chat application in twisted in Python. I am using transport.write() to write to the TCP stream.
However, sometimes, I notice that the data received at the client side is combined( concatenated).
Is there any way that, we could clear the buffer or flush the data, so that data is received as it is sent and not buffered?
Thanks
This is basically the same as this FAQ item:
http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#Whyisprotocol.dataReceivedcalledwithonlypartofthedataIcalledtransport.writewith

Send an xmpp message to all connected clients/resources

How can I send one XMPP message to all connected clients/resources using a Python libraries for example:
xmpppy, jabber.py, jabberbot. Any other commandline solution is well.
So far I've only been able to send an echo or a single message to only one client.
The purpose is to send a message to all resources/clients connected, not grouped.
This might be triggered by a command but is not 'really' necessary.
Thank you.
I cannot give you a specific python example, but I explain how the logic works.
When you send a message to a bare Jid then it depends on the server software or configuration how its routed. Some servers send the message to the "most available resource", and some servers send it to all resources. E.g. Google Talk sends it to all resources.
If you control the server software and it allows you to route messages to a bare Jid to all connected resources then this would be the easiest way.
When your code must work on any server then you should collect all available resources of your contacts. You get them with the presence, most libraries have a callback for this. Then you can send out the messages to full Jids (with resources) in a loop.
I think If you set the same priorities for all connected resources, It would work but I did not try actually.
However in ejabberd there is a module named Mssage Carbon which do this for you, this feature or property is also available in open fire under the name of "route.all-resource".
Hint: If Message carbons used, XMPP client library should suport this too for making it working.

How Get Message from TCP/IP Python?

how do I get the message that more than two messages in the buffer in the TCP / IP connection in python if I use the XML-RPC. I've tried using Cherrypy if the message is received by a normal state if more than one it will not get the message.
About the best answer you will get is to switch framework to twisted. Twisted makes networking laughable because of its simplicity
http://twistedmatrix.com/documents/current/web/howto/xmlrpc.html
Here is a tutorial for xml rpc using twisted.

Talking with a Bittorrent client listening on a port?

I have one of my computers seeding a torrent file on port 45000. I am trying to write a small client in python (or perhaps perl) that helps me to determine the types of messages this client supports for which I need to perhaps do a handshake with the client. In Azureus, this is done using a call like peer.getSupportedMessages(). Is it possible to do this using some library in python or perl?
An example of the returned messages would look like this:
BT_KEEP_ALIVE
BT_PIECE
BT_REQUEST
BT_UNCHOKE
BT_UNINTERESTED
BT_SUGGEST_PIECE
BT_HAVE_ALL
BT_HAVE_NONE
BT_REJECT_REQUEST
BT_ALLOWED_FAST
BT_LT_EXT_MESSAGE
BT_DHT_PORT
lt_handshake
ut_pex
From what I can tell, the list of supported messages is a part of a custom handshake message supported only by Azureus (and possibly some Azureus-compliant tools) and is not part of the official BitTorrent system. However, you can probably craft a bencoded AZ handshake, send it to your seeder, decode the response, and see what the supported messages are.
AZHandshake.java has the details of what the message should look like.
Using the Bencode module from CPAN, you could do something like:
my $handshake = bencode {
identity => '', client => '', ... }; # All fields from AZHandshake.java
# send handshake to seeder and get a response
my $handshake_response = ...
my $dictionary = bdecode $handshake_response;
print join "\n", #{$dictionary->{messages}}, "\n";
Of course, the trick will be in setting up a proper handshake that will elicit a valid response from the seeder. Unfortunately, I don't know of anything that will just do it without requiring a little bit of programming work.

Verify RTSP service via URL

I am trying to verify that a video service is provided from an URL in python. I am asking does anyone know of any good libraries to use or a way to do this. I have not found much info for this on the web.
Thanks
Digging around on StackOverflow I came across a previous question asking for an RTSP library in Python or C/C++ .
Linked there is an RTSP library provided by Twisted, and another one called Live555. Have you tried either of these?
I am just reposting the links for convenience.
If you do not want to use a library, as suggested by synack, you can open a socket connection to the given URL and send an RTSP DESCRIEBE request. That is actually quite simple since RTSP is text-based HTTP-like. You would need to parse the response for a meaningful result, e.g look for the presence of media streams.
If you try to validate the URL itself as a valid RTSP URL, I think that it's only the protocol token that changes from http:// to rtsp:// or rtspu://, and implicitly, the default port is no longer 80, but 554.
See RTSP RFC, section 3.2 ("RTSP URL") for more details regarding URL format.
However, if wish to know if "behind" a given RTSP URL there's a running RTSP server, you should actually open a connection to this server, usually using TCP sockets. You can make the "conversation" simply via code, but I suggest you use some kind of a product/library that provides RTSP stack for Python; I don't know if such product actually exists for Python, but there are a few things for C/C++.
I don't believe Live555 provides a python library. However, they do provide source code that can be compiled to build openRTSP. This is a simple command-line utility that will perform the entire RTSP handshake to connect to the server and begin streaming to the client. It also can provide statistic measurements (such as jitter, number of packets lost, etc.) that can be used to measure the quality of the streaming connection.

Categories

Resources