Google PUB/SUB publish message over C socket connection - sockets

I am trying to find a way to connect Google pubsub directly over a socket connection written in C language. Is their a way to do that? I will be publishing JSON and/or Binary messages over the socket. Is their a specific message format that needs to be followed.

Related

Socket VS Message Broker

Scenario
We are developing a cypto coin exchange platform.
The data feed is in real time and its from multiple sources, users can listen to global channel which transports everything or it can connect to a specific channel which will transport only data for that x coin. The platform should be able to handle two-way communication between client and server.
Question
Should we use a socket server and to relay every msg from the data feed to the users or should we use a message broker (ex: RabbitMQ, Kafka) ?
In case we use a socket server should we use 2 instances one for the data feed and one for the two-way communication ?

Spark Streaming and Sockets

I have an application that will be streaming data in from an IRC server in Python. Currently, I'm creating a socket object in Python that connects to the IRC server. Before I can receive the data, I send the socket authentication initially and may have to periodically send other messages throughout the streaming process. The problem is, I want to stream the messages in with Spark.
I've read that you can create CustomReceivers to do something like this, but I can't find any information on creating one in Python.
Now, I have two possible solutions that I could implement, both of which I feel are sub-optimal.
1) Create a Python socket that connects to IRC and parse/save the data directly without using Spark.
2) Create a Python socket that connects to IRC, send that data to another local Python socket, and have Spark connect directly to that socket and stream from there.
Am I trying to solve the wrong problem with the wrong tool or is there a way to send data to a socket in Spark, namely, in Python?

Receiving TCP packets as messages instead of using gen_tcp:recv/2

I'm writing a distributed chat application in Erlang for my own learning/benefit. I have a client and a server which maintain a persistent TCP connection. The client initiates the connection using gen_tcp:connect/3. The server is actually distributed over several nodes.
The gen_tcp documentation says:
Packets can be sent to the returned socket Socket using send/2. Packets sent from the peer are delivered as messages:
{tcp, Socket, Data}
Because of this, my client is able to receive any data the server sends as a normal Erlang message. This is desirable for my application.
The problem is that I can't see any way to make the connection on the server act the same way. I would love it if my server could receive sent data as an Erlang message. This way, the server can send data (i.e. when another person in the chat room sends a message) while waiting for the client to send a message.
Is there any way to implement this behavior?
EDIT: I'm aware of prim_inet:async_accept/2, but I'd prefer a documented approach if possible.
Look at inet:setopts with option {active, once|true}. Good article about

binary based xmpp server?

Helo, I'm working on a mobile game which needs realtime communication from client to server.
Usually I'll implement a TCP socket server and use some private binary protocol to enable bidirectional communication, and now I also looking into XMPP server like Ejabberd which is based on standard. But XML in some way it's really redundant and inefficient, especially for mobile app it could means more traffic and memory consumption.
Is it a MUST that XMPP use XML?
Is there any XMPP implementation that uses binary as low level data format instead of using XML? (or I shouldn't choose XMPP and start with other standard or technology.)
Any strategy to reduce overhead of sending complex data object (not big file object) using XMPP?
XML is required by the XMPP specification, so there are no binary implementations. It does indeed contain much more overhead, but you have to keep in mind the problem XMPP is designed to solve - an active chat connection can be expected to transmit maybe one message per second.
As for the Google talk api: they use a non-xml protocol for client - Google server connections. When I send a message in the Gmail client, the request body just contains a bunch of post data:
count=1&ofs=16&req0_type=m&req0_to=my.friend%40gmail.com&req0_id=6A8466CBC59CBB0C_0&req0_text=test&req0_chatstate=active&req0_iconset=classic&req0__sc=c
That part is not XMPP. The server which accepts this request then does the job of creating and sending out the XMPP requests. The XMPP is still in XML, they just use a different protocol between the client and Google server.

Xmpp server to server using protobuf

I am tasked with creating a text messaging system with low bandwidth server to server connections. The other developers already use protobuf to send data for other parts of the system between these same server locations, and it would be helpful to continue that trend for the text messaging portion. Server to client connections are not bandwidth constrained. It would be great to be able to use an unmodified chat client and openfire xmpp server.
What is better to program in this situation, a component for openfire or a transport for Kraken?
Have you tried enabling XEP-138 compression on the server-to-server link? Even if OpenFire doesn't support XEP-138, it will be easy to add, and should provide better results that almost any naive translation to protobufs.