views:

236

answers:

3

Hey people!

Currently I'm working on a C/C++ cross-platform client/server software. I'm very experienced developer when it comes to low level socket development. The problem with Berkley sockets/Winsock, is that you always have to make some kind of parser to get things right on the receiver side. I mean, you have to interpret data, and concatenate packets in order to transmit correctly. (packets often get sliced)

Have in mind that the communication is going to be bidirectional. Is pure socket the best way to transmit data nowadays? Would you recommend SOAP, Webservices or another kind of encapsulation to this application?

+1  A: 

These days many people use Web Services and SOAP. There are C++ packages available for this purpose. These will use sockets for you and handle all the data wrangling. If you are on Unix/Linux, give or take System V.4 network handles, your data will eventually travel over sockets.

On Windows there are other choices if you only want to talk to other Windows boxes.

You could also look into CORBA, but it's not the common practice.

bmargulies
+1  A: 

In any data transfer, there is going to be a need to serialize and deserialize the objects.

The first question you want to ask is whether you want a binary or text format for the transfer. Binary data formats have the distinct advantage that they are totally easy to parse (provided they are simple POD structures - you can just cast them into a struct).

Text based transfers should be easier to debug since you can just read the text. You are still going to have to parse them.

SOAP based web services are simple XML based packets sent normally over HTTP. Something will have to parse the HTTP and the XML. The ease of use is not intrinsic but rather dependent of the tools at your disposal. If you have good tools, the by all means, but the same applies to any form of data exchange.

You can take a look at the Boost Serialization Library. It is a fairly complex library and does require you to write code indicating what members need to be serialized. IT does have good support for both text (including xml) and binary serialization. It is also cross platform.

doron
If you have the same architectore on both sides of the transfer, there is no need to serialise.
anon
Serialization is the easiest part. I think the worst part is to parse, the objects on the receive buffer and extract them.That's why I asked.
gmuller
Parsing is the process of deserialization. If you use binary fix sized structures, you do not need to do any parsing what so ever - you just dump the bindary data into the relevant structs.@Neil - even if you have the same architecture, you need to take a possibly complex representation of your data in memory and somehow send it byte by byte down the wire viz. serialized.
doron
+4  A: 

I can highly recommend Google Protocol Buffers.

JesperE