Connecting a SFML client to a C server - c++

I'm wondering whether (and how) I'm able to connect a client created with the C++ SFML to a basic C server.
I know transfering data is normally done using SFML's sf::Packet objects using the send and receive functions from the sockets.
Please note that this is a school project. The connexion isn't restricted to SFML, but the receiving server must be written in C.
The server is already functionnal, and it uses dprintf() to write on the C clients, so ideally I'd be able to do the same with the C++ client.
EDIT_1: sf::Socket.send() doesn't only support sending sf::Packet objects, but also void*. In my case, I need to send and receive strings so that's a first hypothetical solution.

SFML is only for C++. you need to use CSFML its official binding for C

Related

Reading, Creating, and Manipulating full Frame in TCP/IP network communication via C++ coded client and server

I would like to code my own client and server in C++ (which I have found plenty of tutorials on) and access to all information about the headers and all the fields in a frame that is going to be sent across a network.
I need it to be able to edit and/or manipulate information in all the header fields before sending the frame across the network. What's more, it needs to be able to receive a frame and read/manipulate all the header fields from layer 2 to up layer.
I just want to know what library in C++ I need to use or is there any information on how I can code something to accomplish this via C++ that I can be directed to?
If you want to construct a client/server, it's easy. But if you want to build a packet from MAC to Transport Layer, then you need to use the Linux kernel. You need to have some knowledge about how the packets are sent and received. What's more, we always use C to realise it.

Server/Client program for data transfer. What is the professional, right way to do it?

For my scientific collaboration, I wrote a C++ server/client (terminal server for linux, and cross-platform GUI client using Qt) that is mainly meant to transfer data from multiple clients around the world to store it on one server for analysis (pretty much like LIGO and Virgo that caught gravitational waves). For the communication low-level protocol I used boost::asio::ssl.
The "odd" part: In my programs, I created my own half-duplex messaging protocol between the server and the client from scratch. The messaging was in string form containing the version of the protocol, endianness of the computer, length of the message, type of the message (login/file/error/etc...), an MD5 hash for verification of the completeness of the transferred data. I got highly criticized on Stackoverflow chat when I said I did this. The part that got specially criticized is: Writing my own messaging protocol.
Now I created this, and I know there should be better protocols that are already written that I shouldn't rewrite it from scratch. However, I wanted to learn how to do this myself, and I did, and the program works, and my collaboration is satisfied, and the sky is blue with birds singing.
My question: If I am to rewrite this program again, what kind of libraries should I use? I'm looking for a protocol, using which I can send messages/data and get the server to respond with messages/data, including username/password to authenticate the user before any communication is transferred? How would you have done it?
PS: Please consider this question coming from a beginner in writing network and internet wide programs. And please don't hesitate to ask for more details.

C++ Non-QT interface and QtNetwork

I'm part of the RoboCup SSL of my school and we try to simulate the entire game on the grSim simulator (https://github.com/mani-monaj/grSim).
grSim is a Qt application so I have used the Qt Network library to make a client/server app and receive Google protobuf data. (https://github.com/rjabaker/WarBots-StrategyTester/tree/master/tester/comm)
I have try to make the samething with SSL-refbox, I receive data, but it's not working when I try to print out the data, so I try to figure out why..
** So my question is: Can I use the Qt Network library to make a client/server app and receive data from a non-Qt interface (SSL-Refbox https://github.com/Hawk777/ssl-refbox/)**
Yes -- the Qt network library doesn't specify any particular protocol, it just shovels bytes around. So there is no reason a Qt-network-based server can't talk to a non-Qt-network-based client, or vice versa; you just have to make sure that they both speak the same protocol.

C++: Cloud computing library: is there such a library where I don't need to write much network stuff?

I want my server app to be able to send data to be processed by a bunch of various clients, and then have the processed data returned to the server.
Ideally, I'd have some call like some_process = send_to_client_for_calculating(connection, data)
I just need to be able to send a bunch of data to a client, tell the client what to do (preferably in the same message, which can be done with an array [command, data]), and then return the data...
I'm breaking up pieces of a neural network (tis very large), and then assembling them all later.
If I need to be clearer, let me know how.
I'm shocked no one has thrown it out there... how about boost::asio.
Why don't you have a look at using Apache ActiveMQ? It's a Java JMS server, but it has C++ bindings, and does what you want with a minimum of writing networking code. You basically just subscribe to messages, and send responses back. The MQ server takes care of dispatch and message persistence for you.
You could try using beanstalkd, a fast working queue. I don't know if it fits your purposes. There is a client library written in C, which you should be able to use from C++.
I'd suggest looking at gSOAP, which implements SOAP in C++, including networking.

TCPStream Class for multithreaded TCP server

I'm currently working on transitioning a small console application to a TCP server / client application. The client will connect to the server via any Telnet client, and the server will replicate the standard console interface for each Telnet connection.
I started looking into doing this using the techniques I've learned from Beej's guide to network programming -- accepting the connection and then using fork() to separate it into its own process.
However, I would prefer to maintain my use of streaming IO (the original console application uses cin / cout, using similar functions for the networking logic would make the conversion process much simpler).
I've discovered the TCPStream class, hiding within sockets.h (http://www.gnutelephony.org/doxy/bayonne2/a00215.html)
It appears this class will allow me to use the server with streaming IO. However, I can't find a single example of using this class, nor can I find an explanation as to how to use fork() with it.
Any ideas? Thanks in advance for any help.
I think you are confusing the trees for the forest. One socket class is such a small part of what you need to do overall that it is not worth focusing on that.
If your objective is just to get your project working then just use an existing framework rather than trying to pull individual classes out of a large project. POCO has a TCPServer class that will do 90% of the work for you. QT, ACE and others have similar classes. There is not a huge amount of documentation on POCO but they do cover TCPServer pretty well and you can learn a lot from reading the source code if that is really where your interest lies.