SFML community forums

General => SFML projects => Topic started by: binary1248 on November 30, 2013, 04:32:03 am

Title: SFNUL
Post by: binary1248 on November 30, 2013, 04:32:03 am
SFNUL - Simple and Fast Network Utility Library

I originally intended it to just be called NUL, but go figure why I couldn't name it that... I guess the SF is fitting because if you ask me, it sticks with the SF philosophy somewhat :).

Background History
SFNUL was envisioned a veeeery long time ago, while I was still actively working on my super awesome project Wyrm (https://github.com/binary1248/Wyrm) before even touching SFGUI because Wyrm needed a UI :). Back then I already considered making the networking more reusable because I tended to have to rewrite the exact same code in every networked game I coded, and it got quite annoying. Time passed, and I had more interesting things to do (http://en.sfml-dev.org/forums/index.php?topic=6112.0) than actively work on Wyrm so that idea kind of went with it for a while.

It wasn't until helping Jungletoe debug his network related problems earlier this year that I realized SFML networking had a lot of shortcomings that I also found annoying, not only because I found that it didn't provide a level of abstraction of networking that was high enough, but because in certain situations it sacrifices standards conformance for a bit of usability. Being a computer science student for so long, I've come to revere standards which is why SFNUL aims to warn the developer about non-standard behaviour that they might cause.

General Idea
The main goal of SFNUL is to cut down on the network boilerplate code that can be seen in most multiplayer games. I already experienced this first hand while working on Wyrm, and browsing through the SFML network forum reviewing code and problems many have, I've gotten a feeling for what multiplayer game developers might need to spend less time writing "the same old annoying code that has to be written in every single project". SFNUL's sole purpose is to give developers more time to work on the code that makes their project unique from all others instead of code that is common among all projects. I want to see less code/problems and more playable multiplayer games ;).

Features
Fully asynchronous socket API.
Process data according to your own pace, it will trickle into an internal buffer but this doesn't mean you need to dedicate a thread to a blocking call or resort to selectors to check if any data is available. If data is available, you will be able to retrieve it and process it, if not then do something else.

Fully asynchronous TCP connection establishment/accept.
TCP connections will continue trying to connect and will automatically transmit/receive queued data when it is established. Incoming TCP connection requests are also queued into an internal buffer for you to process when you are ready.

TLS/SSL support.
You can set up a TLS transport and use it like you would use a TCP connection. All TLS specific features are added on top of the ReliableTransport interface which a normal TCP socket also implements.

HTTP/HTTPS client support.
Send arbitrarily constructed HTTP requests through the HTTPClient and it will receive and parse the reply sent back from the server which you can pick up from the HTTPClient, as with everything else, when you feel like it. HTTPClient supports HTTP/1.1 chunked transfers, persistent connections and request pipelining for efficient throughput utilization.

sfn::Message
Those familiar with sf::Packet will understand how sfn::Message works. It is the SFNUL version of sf::Packet that can do a lot more useful things ;). Let's use some code to demonstrate the differences:
sf::Packet packet;
sfn::Message message;

std::vector<int> vec = { 1, 2, 3, 4 };

packet << vec; // Doesn't compile, no operator<<( const std::vector<int>& )
message << vec; // Compiles, all objects that conform to the STL container interface are supported.

// Nesting containers works as well.
std::vector<std::list<std::deque<std::string>>> something;
// Insert some data here...

message << something; // Works fine.
message >> something; // Works fine as well.

int i = 42;

packet.prepend( &i, sizeof( i ) ); // Doesn't exist. No easy way to prepend data to a packet.
i >> message; // Intuitively insert data into the front of the message to prepend.

struct A {
        int a, b, c;
        float d, e, f;
        char g[16];
};

A a;

packet << a; // What?? How could this possibly be implemented?
message << a; // Yes... this works... any trivial data type is supported for insertion and extraction.
message >> a; // Just to complete the cycle.

Links
Did you ever wonder how you can separate multiple different networking concerns from each other when communicating between hosts? Say you need to transmit data every time the player hits a key to move, that is one concern, then you need to transmit object states, that is another concern, and on top of that the players want to chat with each other, yet another concern. A typical approach would be to label each of these with a separate packet type ID to properly identify their payload, or the worse solution that many big games go for: open up multiple connections between the same pair of hosts. With the sfn::Link, that is taken care of automatically. sfn::Link multiplexes multiple distinct streams into a single network connection and demultiplexes them at the other end. All you need to do is assign each concern a stream ID and send/receive over that stream when dealing with that concern.

Object Synchronization
The centrepiece of SFNUL, seeking to solve the most annoying part of multiplayer coding. When you have multiple hosts which share the same world state with each other, performing the proper synchronization between them can become quite a tedious task. You need to assign IDs, perform required serialization/deserialization, object lifetime management, connection management and many other annoying things that have nothing to do with your vision of the game. This is where the sfn::Synchronizer comes in. Simply put: The sfn::Synchronizer makes sure that state changes to objects that it manages are propagated to synchronized remote hosts automatically without any extra coding effort from the developer. A simple example with a lot of things omitted for demonstration purposes:
class Blob : public sfn::SyncedObject {
public:
        // ... type id / constructors omitted ...
        sfn::SyncedInt32 x;
        sfn::SyncedInt32 y;
        sfn::SyncedType<sf::Color> c;
};

sfn::SynchronizerServer synchronizer_server;
auto blob = synchronizer.CreateObject<Blob>();

sfn::SynchronizerClient synchronizer_client;
// We assume the blob is already created on the client for brevity sake.

// On the server we do:
blob.x = 10;
blob.y = 20;
blob.c = sf::Color::Green;

// On the client we do.... absolutely nothing. The changes are performed automatically.
No more wasted time on getting the synchronization up and running and even more wasted time debugging it when it doesn't work. Do what you would do for a single player game and get multiplayer for free... in some sense :).

Here is a diagram showing how the SFNUL facilities and dependencies can interact with each other:
(http://i.imgur.com/yzgfTkG.png)

These were very brief examples/descriptions of the ideas behind SFNUL. If you want more demonstrations (that also work) look in the examples directory.

OK, enough with the features, where's the...
Yes... the repository can be found at GitHub: https://github.com/binary1248/SFNUL

If it isn't already apparent, SFNUL makes very heavy use of C++11 features. This means that you not only need a compiler that can compile C++11 code somewhat, but one that is feature complete and more importantly conforms to the standard. This already rules out Visual Studio 2012 and earlier, so if you haven't hopped on the Visual Studio 2013 train, well this could be another reason to consider if you want to try SFNUL.

SFNUL is licensed under the Mozilla Public License Version 2.0. Put simply, it is a file-based license, as long as you don't modify any of SFNUL's files you are free to do/distribute whatever/however you want, all subject to the terms of the MPL of course. If you distribute software using modified MPL code, you need to make available the modifications under the MPL as well. See this as a contribution back to the open source community for all of its efforts you have taken advantage of in the past ;). As with any other license, read through the MPL text if you want to understand what you can/cannot/have to do.

Frequently Asked Questions
Q: Where are the pre-compiled libraries for XYZ compiler?
A: Learn to compile something yourself, it isn't as hard as you think.

Q: I downloaded the zip archive off GitHub but it's complaining about missing headers during compile. Why?
A: zip archive won't work. Clone via git and initialize all submodules. Explained in the README.

Q: But I don't have git, surely there must be another way?
A: There is another way, it's called install git and use it.

Q: Wait... so what has this got to do with SFML?
A: Initially, it interacted a lot with SFML's classes, but then I realized that it would be easier for me to implement my own take on SFML's classes with many more features I found were missing and were feasible with C++11. So right now, it has very little to do with SFML. It can even be used independently of SFML. But you will recognize a bit of SFML's interface design still left in SFNUL.

Q: Do you plan on ....
A: Yes I have plans for a lot of things, and they will be implemented when I have a general idea of how to implement them. Either that, or I run into a dead end in one of my other projects and know that it is something SFNUL should be able to solve, so I implement it into SFNUL to be able to use it in the project and share it with the world at the same time.

Q: I know this isn't a question but I found a bug and I am sure it isn't intended behaviour described in a footnote of the documentation.
A: GitHub tracker.

Q: Where is the documentation?
A: doxygen inside the doc directory, or just generate the doc target in CMake.

Q: This is too complicated for me. Is there a simpler way?
A: What? This is supposed to make your life simpler. Write a few games with decent network support and come back here so that you can realize how that question doesn't make much sense.

Q: Are those the only questions in the FAQ?
A: Nope, more will be added if needed.
Title: AW: SFNUL
Post by: eXpl0it3r on November 30, 2013, 11:06:26 am
Everyone is so overwhelmed with your awesomeness, that they don't manage to say anything. :D

As a tester and to some extend user of SFNUL I can only recommend this library. I've never really done any network programming, but with SFNUL it indeed is very easy to achieve what you want, without having to worry about "low level" stuff.
I certainly will make further use of SFNUL whenever possible. ;)
Title: Re: SFNUL
Post by: Nexus on November 30, 2013, 11:45:13 am
Definitely a very interesting project!

My networking experience with SFML is limited, but I can confirm that it takes quite some time to get things right. A library that simplifies that would definitely be very helpful. Also, it's amazing to see secure connections over SSL/TLS. It was probably not too easy to implement that with certificates and everything (I don't know how much the underlying libraries already do here)...
Title: Re: SFNUL
Post by: binary1248 on November 30, 2013, 12:43:14 pm
It was probably not too easy to implement that with certificates and everything (I don't know how much the underlying libraries already do here)...
SFNUL uses TropicSSL for its TLS/SSL layer on top of a normal TCP socket. This means that the transport layer is still taken care of by SFNUL which itself relies on asio instead of letting TropicSSL resort to its standard POSIX socket calls. TropicSSL is the last revision of what is now named PolarSSL that was licensed under the BSD license, but if you consider that no big advancements have been made in the crypto-scene in the last few years, there isn't much of a difference.

SFNUL was designed to be built up in layers (see diagram I added to the original post). Mixing multiple layers together in different combinations to achieve what you need easily is the goal. At the moment most combinations (including exotic ones) work, but a few more obvious ones don't work due to technical reasons. This might change in the future.
Title: Re: SFNUL
Post by: Laurent on November 30, 2013, 06:42:11 pm
This looks awesome. I'm sure I'll find many interesting ideas in it for sfml-network 3.0 :)
Title: Re: SFNUL
Post by: Lo-X on December 02, 2013, 11:18:41 am
I'm speechless :o

I just get myself in a networking game and as for now I think I'm going to use your framework.

The SyncedObject thing look awesome, I didn't even imagine such a thing. More snippets/examples may help (especially client-side, since you show only server-side).
The message version of packets will be sooo usefull as well, even if we could do it before with (some) extra code, definitely will make life simple !

A.W.E.S.O.M.E

Edit : why did you used CamelCase instead of camelCase for methods :( ?
Title: Re: SFNUL
Post by: binary1248 on December 02, 2013, 03:30:11 pm
The SyncedObject thing look awesome, I didn't even imagine such a thing. More snippets/examples may help (especially client-side, since you show only server-side).
I kept it simple in the snippet so that people can understand the general idea without having to read 10 pages of code. A fully functional example of both client and server sides can be found with the source code in the examples directory.

Edit : why did you used CamelCase instead of camelCase for methods :( ?
I was just used to it ;D. Would you ask this question if SFML still used CamelCase? Maybe it's a good thing that different libraries use different naming conventions, easier to distinguish where an object comes from :).
Title: Re: SFNUL
Post by: Lo-X on December 02, 2013, 03:45:34 pm
The SyncedObject thing look awesome, I didn't even imagine such a thing. More snippets/examples may help (especially client-side, since you show only server-side).
I kept it simple in the snippet so that people can understand the general idea without having to read 10 pages of code. A fully functional example of both client and server sides can be found with the source code in the examples directory.

Yeah, I saw that afterward, I've what I needed (for now :p )

Edit : why did you used CamelCase instead of camelCase for methods :( ?
I was just used to it ;D. Would you ask this question if SFML still used CamelCase? Maybe it's a good thing that different libraries use different naming conventions, easier to distinguish where an object comes from :).

I'm used to camelCase, I used to wonder why SFML used CamelCase back in 1.6.
You're right and wrong for the origin of objects. If we only use your lib (or very few) we can know it. But as soon as you use multiple libs, it mixed up between camel and Camel.
I said that because I like my code to be "nice" (in the aspect way), consistent. And I'm used to STL and/or Boost and/or Qt (and now SFML) and their camelCase convention.

It wasn't a request, I just wanted to know if there was any reason.
It doesn't withdraw any quality or amazing-ness from your lib :p I'll test it further this evening.
Title: Re: SFNUL
Post by: binary1248 on December 02, 2013, 04:17:58 pm
Doesn't STL use cpp_case? I was actually considering using cpp_case but I figured I don't want to step on the hallowed ground of STL/boost and scare people away :). That and I would get confused between functions and my own variables which already use cpp_case :P.
Title: Re: SFNUL
Post by: Lo-X on December 02, 2013, 05:13:58 pm
Doesn't STL use cpp_case? I was actually considering using cpp_case but I figured I don't want to step on the hallowed ground of STL/boost and scare people away :). That and I would get confused between functions and my own variables which already use cpp_case :P.

Yes you're right, I was too fast and I dunno how I could forget how much I dislike cpp_case (it's indeed scary).
That's surely because I have basics methods in mind, like size() empty() stuff()

Is it possible to take just a part of your lib ? Essentially I don't need all the SSL stuff (for now) but I would like to use the "basic" network part, for games. I would like to adapt it to my code and learn how you did all that, so I'm rather thinking about re-(copying)-coding it if it's possible (with credits where it's due, of course) ?

Edit: it could sove my very big issue with camelCase ;p
Title: Re: SFNUL
Post by: binary1248 on December 02, 2013, 06:59:06 pm
If you release the networking code under the MPL as well, I don't see why you couldn't take parts of it and modify it for your own purposes... The TLS functionality is coupled to the HTTP client so if you don't want to have it, you have to remove HTTP support as well. But I don't see why it would be a problem to just leave TLS support in the library. What ends up in your final executable is what you actually use (if linking statically). If you want to thin down the library for dynamic linking then yes, you will have to manually get rid of parts yourself.
Title: Re: SFNUL
Post by: Lo-X on December 02, 2013, 07:18:13 pm
If you release the networking code under the MPL as well, I don't see why you couldn't take parts of it and modify it for your own purposes... The TLS functionality is coupled to the HTTP client so if you don't want to have it, you have to remove HTTP support as well. But I don't see why it would be a problem to just leave TLS support in the library. What ends up in your final executable is what you actually use (if linking statically). If you want to thin down the library for dynamic linking then yes, you will have to manually get rid of parts yourself.

Yeah no that's not a question about how much of the lib I want in my executable, I don't care :p That's about how you did things, perhaps why and what I would have done differently. Learning purposes, since I did some (few) networking for 2/3 games, I'm curious about your SyncedObjects and stuff like that
Title: Re: SFNUL
Post by: TypeOverride on December 21, 2013, 10:34:50 pm
Ive try to run the library under Visual Studio 2012.

It cant be run because tropicssl doesnt work with Visual Studio 2012, because Visual Studio 2012 has no <inttypes>
So ive used http://code.google.com/p/msinttypes/ for the inttypes.

But there are enough other errors under Visual Studio 2012 that makes the library kind of hard to build.
Title: Re: SFNUL
Post by: zsbzsb on December 21, 2013, 11:47:02 pm
Ive try to run the library under Visual Studio 2012.

It cant be run because tropicssl doesnt work with Visual Studio 2012, because Visual Studio 2012 has no <inttypes>
So ive used http://code.google.com/p/msinttypes/ for the inttypes.

But there are enough other errors under Visual Studio 2012 that makes the library kind of hard to build.

Don't you even read the original post?  ???

Quote
If it isn't already apparent, SFNUL makes very heavy use of C++11 features. This means that you not only need a compiler that can compile C++11 code somewhat, but one that is feature complete and more importantly conforms to the standard. This already rules out Visual Studio 2012 and earlier, so if you haven't hopped on the Visual Studio 2013 train, well this could be another reason to consider if you want to try SFNUL.
Title: Re: SFNUL
Post by: TypeOverride on December 21, 2013, 11:48:28 pm
Yes i read it. I try to make it runnable in vs2012

One other question is how others compile this library when he say that vs2012 cant be used. And a compiler is not enough.

Quote
This means that you not only need a compiler that can compile C++11
i dont understand what he means. What is it what i need beside a C++11 compiler that uses C++11 features heavily?

What i did was:
1) Using GIT loading the project (i recognize that the extlibs are not downloaded), so
2) ive GIT loaded all the extlibs too.
3) used CMake an making a VS2012 project
4) fixed the problem with tropicssl and the missing inttypes header in vs2012
5) then i saw the heavy used C++11 features for which i have to use an other compiler i think  - didnt make it at the moment, because ...

... perhaps its easier... because of that i ask here how others like you would compile SFNUL?
Title: Re: SFNUL
Post by: eXpl0it3r on December 22, 2013, 12:19:14 am
Maybe someone needs to repeat it in plain text:

You can not build SFNUL with Visual Studio 2012! ;D

SFNUL uses C++11 features that are not supported by the compiler of Visual Studio 2012. If you want the library you need a compiler that supports more or at best all C++11 features. MinGW GCC 4.8.1 and above should work fine. Visual Studio 2013 might work, haven't managed to build it yet though.
Title: Re: SFNUL
Post by: TypeOverride on December 22, 2013, 12:39:35 am
Maybe someone needs to repeat it in plain text:

You can not build SFNUL with Visual Studio 2012! ;D

SFNUL uses C++11 features that are not supported by the compiler of Visual Studio 2012. If you want the library you need a compiler that supports more or at best all C++11 features. MinGW GCC 4.8.1 and above should work fine. Visual Studio 2013 might work, haven't managed to build it yet though.

Yeah i know. But i didnt know any other way to compile a library. So my question is how compile it, without using visual studio?

At the moment
Quote
You can not build SFNUL with Visual Studio 2012!
means for me i cant compile it because i have no knowledge of compiling without visual studio. So the question is how to compile it without visual studio?
Title: Re: SFNUL
Post by: binary1248 on December 22, 2013, 02:08:16 am
means for me i cant compile it because i have no knowledge of compiling without visual studio. So the question is how to compile it without visual studio?
Sorry if this sounds offensive, but that question makes no sense whatsoever. If you want to use any library with Visual Studio, you must have compiled it with Visual Studio (yes... there are other ways but that is beyond the scope of this discussion). Simply put: You can't make use of SFNUL unless you compile it with Visual Studio. So asking how to compile it without so you can use it with makes no sense.

But really, it isn't that hard to install Visual Studio 2013, even side-by-side with 2012. After all it is a Microsoft product that runs on any modern Windows. You can just blindly click through the installer with all defaults and it will work for 99.99% of your projects.

As already stated before, it is known that SFNUL doesn't compile with 2012 or earlier, and there can be no "fix" for this because the library is C++11 code. Rewriting it so it compiles in 2012 would mean removing almost everything in SFNUL, and that obviously makes little sense.
Title: Re: SFNUL
Post by: TypeOverride on December 22, 2013, 02:36:44 am
I have a Visual Studio 2012 Professional and know i have to use the Express Edition .. hmmm not so nice.

But this is the only way. I have to port all my applications to the next level. Ive did this before and it is always a mess.
Title: Re: SFNUL
Post by: binary1248 on December 22, 2013, 02:47:47 am
Do you really think I support such a non-conforming compiler with money? Of course not, not when GCC and clang are available for free and are fully conforming. I only use the Express versions of Visual Studio to test compatibility when there is any doubt. They were always free and could do almost everything you could possibly need in a non-professional environment.

And for those who wonder, I only make use of the compiler, not the IDE. So it is cl vs g++ vs clang++. cl loses in everything hands down.
Title: Re: SFNUL
Post by: TypeOverride on December 22, 2013, 02:51:15 am
Do you really think I support such a non-conforming compiler with money? Of course not, not when GCC and clang are available for free and are fully conforming. I only use the Express versions of Visual Studio to test compatibility when there is any doubt. They were always free and could do almost everything you could possibly need in a non-professional environment.

And for those who wonder, I only make use of the compiler, not the IDE. So it is cl vs g++ vs clang++. cl loses in everything hands down.

Ok. I feel alot of anger against microsoft i think. But its ok. I hate their attitude too. So much nice technology they have but always bound on their systems.
Title: Re: SFNUL
Post by: TypeOverride on December 22, 2013, 03:00:06 am
Ive do this:

Install Git.
Install CMake.

Git:
make a folder for the project on C for example -> C:\SFNUL (RightMouse on folder -> Git Bash)
$ git clone https://github.com/binary1248/SFNUL.git

for C:\SFNUL\SFNUL (RightMouse on folder -> Git Bash)
$ git submodule update --init --recursive

CMake with Visual Studio 2013 config:
Where is the source code: C:/SFNUL/SFNUL
Where to build the binaries: C:/SFNUL/SFNUL

But its not working for Visual Studio 2013. Platform Toolset is v120 (latest) under Visual Studio 2013.

Error   2   error C2610: 'sfn::Thread::Thread(sfn::Thread &&)' : is not a special member function which can be defaulted   C:\SFNUL\Concurrency.hpp   28   1   sfnul


I know now from you that C++11 compiler standard maybe not be 100% in Visual Studio with the native compiler. But i dont want a different one because different compiler means different problems i think.

I only have to change the = default C++11 for autogenerate the constructor. Not a big change, but makes it run under the latest Visual Studio native Compiler.

So i think the only way is for me to downgrade the library to a standard that can Visual Studio Toolset v120 (latest compiler) read.

You've said
As already stated before, it is known that SFNUL doesn't compile with 2012 or earlier, and there can be no "fix" for this because the library is C++11 code. Rewriting it so it compiles in 2012 would mean removing almost everything in SFNUL, and that obviously makes little sense.

I dont know if i understand. You say you have to rewrite all of the code for VS2012 that it runs under the native compiler Toolset v110, because the library uses C++11 code. v110 in VS2012 is C++11 too. Perhaps not has all features of it. 

I see too there are a lot of dependencies like boost too -> # include <boost/array.hpp> or <boost/weak_ptr.hpp> <boost/shared_ptr.hpp> which are not included in the project. Most people like me dont like boost because of the overhead you get of using parts of boost.

At the moment i see only the = default (C++11) only as problem for VS2012 or VS2013. But i will see more when i removed the all boost dependencies from the project.

I think C+11 standard has shared pointer and other things so you can ignore boost. So boost is not necessary so heavy to use. A lot of things in C++11 comes from boost. So boost is not necessary anymore for the most cases.

So i can use std::shared_ptr instead of <boost/shared_ptr.hpp>.

I see that the boost depencency comes from ASIO and they have a newer build that works without Boost and fully with C++11 features called Asio Standalone: http://think-async.com/Asio/AsioStandalone

It would be great if the awesome binary1248 update his library to the latest version to run it without boost.
Title: Re: SFNUL
Post by: eXpl0it3r on December 22, 2013, 11:50:54 pm
Ok. I feel alot of anger against microsoft i think. But its ok. I hate their attitude too. So much nice technology they have but always bound on their systems.
This has nothing to do with anger, the only think you might read from in between the lines is frustration. It's a fact that Microsoft didn't really try to catch up with the latest standard (C++11) and unfortunately they can just do that, since Microsoft made many companies and private developers depend on VS, that way they don't have to fear any drop in user count/sales.
They were visionary with VS 2010, because that version had already a few features (e.g. smart pointers) before the new standard was finalized, but with VS 2012 they barely even tried to catch up and even with VS 2013 they rather started to implement C++14 features instead of pushing out a fully C++11 conformant compiler.
The other fact is, that VS costs a ton of money if you don't want the Express version.

On the other side, you have the two open source compilers GCC, which essentially has everything implemented (http://gcc.gnu.org/projects/cxx0x.html) for month (http://gcc.gnu.org/ml/gcc-announce/2013/msg00004.html), and Clang, which - now hold your breath - is already C++14 feature complete (http://clang.llvm.org/cxx_status.html)!

So the frustration is really not just based on nothing - you really have to think about, how a company as big as Microsoft is and the money they have, doesn't manage to push out a properly working compiler in time. And not to forget people actually pay a lot for such unfinished work.

Error   2       error C2610: 'sfn::Thread::Thread(sfn::Thread &&)' : is not a special member function which can be defaulted    C:\SFNUL\Concurrency.hpp        28      1       sfnul
Although this should've been fixed with the VS 2013 November CTP (http://blogs.msdn.com/b/vcblog/archive/2013/11/18/announcing-the-visual-c-compiler-november-2013-ctp.aspx) it seems like the toolchain is still bugged (http://herbsutter.com/2013/11/18/visual-c-compiler-november-2013-ctp/#comment-13312).
If you want to make it work, you can change stuff around on your own. The official source however won't get changed due to some compiler no conforming to the standard.

I dont know if i understand. You say you have to rewrite all of the code for VS2012 that it runs under the native compiler Toolset v110, because the library uses C++11 code. v110 in VS2012 is C++11 too. Perhaps not has all features of it.
Visual Studio 2012 only supports some of the features C++11 (http://msdn.microsoft.com/en-us/library/hh567368.aspx) defines in the standard. SFNUL however makes use of features that are not implemented for VS 2012. So regardless whether VS 2012 supports some features, it's still not a fully conforming C++11 compiler and it can't compile SFNUL ever - not with some simple tweak, not with some ugly hack, not with ..., it just won't compile with VS 2012 and you should deal with that.

I see too there are a lot of dependencies like boost too -> # include <boost/array.hpp> or <boost/weak_ptr.hpp> <boost/shared_ptr.hpp> which are not included in the project. Most people like me dont like boost because of the overhead you get of using parts of boost.

I see that the boost depencency comes from ASIO and they have a newer build that works without Boost and fully with C++11 features called Asio Standalone: http://think-async.com/Asio/AsioStandalone

It would be great if the awesome binary1248 update his library to the latest version to run it without boost.
No idea what you're looking at, but SFNUL is already based on a standalone version of ASIO, boost is not required.

Summary
Title: Re: SFNUL
Post by: Nexus on December 23, 2013, 12:43:13 am
Of course it's frustrating that Microsoft is lacking behind, but simply saying "I don't care about VS" while a significant part of people use it is too narrow-minded. Saying "know your tool chains and just use gcc/clang" is even more so, considering that there can be other reasons (http://en.sfml-dev.org/forums/index.php?topic=13553.0) to choose one product over another, and a small part of people may even be bound to a specific IDE at work.

In my opinion, a library developer should at least try to support the most recent versions of all major compilers. Visual Studio 2013 has made a big step forward compared to 2012 concerning C++11 support, so the porting effort should be kept in reasonable bounds. That's just my point of view and the attitude I used while developing Thor -- and it's not a sole problem of VS, even if people like bashing Microsoft. I had to implement several workarounds for g++ and clang over time, for example I rewrote a significant part of TR1 random functionality, and I could not use lambda expressions in specific situation on clang because of a compiler bug.
Title: Re: SFNUL
Post by: FRex on December 23, 2013, 02:01:20 am
In 10(and possibly in next ones but that I don't know) c++ is labelled as 'Visual C++' so I don't know what you guys want, it's just a terribly unfortunate syntax and name coincidence. :P You thought you were buying an ISO c++ compiler or something? ::)

Seriously now:

Quote
simply saying "I don't care about VS" while a significant part of people use it is too narrow-minded
He didn't say exactly that originally, this suggests 2013 will work:
Quote
This already rules out Visual Studio 2012 and earlier, so if you haven't hopped on the Visual Studio 2013 train, well this could be another reason to consider if you want to try SFNUL.

Also you(or one of the very very numerous, as you point out, VS users) are free to port it back to Visual 2012 and 2010.

Quote
people like bashing Microsoft
The f**king idiocy I often run into online about GL, c++ and Linux(thanks to DX, C#/Java and Windows/Mac OS X respectively)  is unbelievable compared to this 100% technically sound 'bashing' of Microsoft about Visual. Also don't make them sounds like innocent victim that can't keep up with their work. It's a company that earns and deals in BILLIONS. It should NOT have its products(VS + MFC) compare unfavourably with gratis, cross platform, FOSS ones like GCC, Clang, GTKmm, Qt and own ones for competing C#(.NET, WPF).
Title: Re: SFNUL
Post by: binary1248 on December 23, 2013, 02:19:27 am
It's not really about Microsoft bashing... it's about their attitude towards their users and their policies on choosing which features to prioritize over others.

Implementing C++14 features before even making sure that all C++11 core language features are done and work sounds to me like some evil lobby doing their work behind the scenes. I always thought that they prioritized some C++14 features over C++11 features because they were much simpler to implement and thus would mean pushing out more new features instead of making everybody wait for a certain highly complex to implement feature of C++11. Looking at the list of stuff they already implemented for C++14 (which isn't even a finalized standard yet) and even proposed C++17 feature(s) I can't help but ask myself: Were those features really much easier to implement than the missing C++11 features? It seems to me like it is just an excuse they thought of to hide the opaque decision making of their management that obviously have certain interests in mind (certainly not standards conformance).

If nobody knew yet, I'm not a fan of using IDE features too excessively. Most of the work I do is through various text editors, and the only time I might actually use an IDE is either during testing or a heavy debugging phase. As such, my opinion might be skewed regarding Visual Studio, as I compare it to other toolchains at a compiler level, and quite frankly, it isn't even fair to compare them because the VC compiler has no apparent advantages over the others that make it worthwhile using outside of the IDE.

Don't get me wrong, the people that we see in public, the "faces of Visual Studio", like Sutter, Lavavej and Brewis are all nice guys. The problem is that they are not the ones making the decisions, those are higher up in management and we will never be able to see them.

For me Visual Studio development is on the outside like a headless chicken, you have no idea where it is going and even if you did know, you wouldn't understand why certain decisions were made. Producing a C++ compiler without standards conformance in mind goes against all my philosophies and is the total opposite of what GCC and LLVM are showing. We know Microsoft earns money off Visual Studio, and if doing what they do makes them more money than doing something else, then so be it. They sure aren't doing the language a favour, just themselves.

As for SFNUL, I am aware that it doesn't build because of that compiler bug, and that is the point. It is a bug, and unless enough people care about it and make noise do you think it will get high priority? Microsoft have already shown how well they prioritize development of the compiler. And my guess is that this bug won't get taken care of as fast as others because it is not something many people even are aware of, considering it is one of the new features of C++11 and we know how many programmers make full use of it already...

You have to look at it like this: Every time Visual Studio (or any proprietary software) has an advantage over GCC (or any other open source software) they tend to sway people over into using the proprietary product just because of those advantages. The better product wins because in this case there wasn't any "pulling force" from the open source software. It is open source, free, use if you want, so they aren't hurt if people stop using it. On the other hand, if the open source software had an advantage, or as in this case isn't bugged in some way, naturally people would flock towards it, if it wasn't for the pulling force from the people making the proprietary software. In this case, it actually does hurt if they lose customers, so they try to make it as painless as possible to use their deficient product although the opposite side has the objectively better product. This "making as painless as possible" can have many manifestations, from the obvious "we'll give you 50% off" to the not so obvious "here are some other features that the other side doesn't have but you might not need". I even go so far as to say that the community influences people into working around obvious deficiencies on their own just so they benefit from the win-win situation.

Honestly, if Visual Studio were able to build ELF binaries and support more features than either GCC or LLVM, I would have no problem using it. I am purely opportunistic, you have to convince me of the real advantages that it would have, and not some marketing ploy.

Put simply: I am just being fair towards the open source community. Every compiler has its advantages and disadvantages, and only implementing workarounds for a specific compiler that doesn't even contribute back to the community isn't fair if you ask me.

Would it be painful for Visual Studio users if every library adopted this way of thinking? Yeah, it sure would. But that is a good thing, because there would be real competition, and Microsoft wouldn't be able to afford treating their customers like suckers any more. There would be progress. And that would be good for everyone and the language itself independent of compiler.

I am a person driven by morals. And this is one of the times when I have to say: Not with me. SFNUL is a very young library, with barely any userbase one could speak of. As such I am not breaking it for existing long time users (SFGUI implemented workarounds... yes) because there are none. And if anybody is wondering, I am not going to pollute SFNUL code with workaround after workaround just to grow the userbase. Standards exist for a reason, and if you use non-standard tools/OS/whatever, then it is your responsibility to make it work for yourself. Besides, as I already said above, SFNUL is aimed at the more advanced developers who are just looking for a way to make themselves more productive. You can see this as an unintended "entry exam" if you want.
Title: Re: SFNUL
Post by: TypeOverride on December 23, 2013, 02:14:11 pm
Quote from: eXpl0it3r
No idea what you're looking at, but SFNUL is already based on a standalone version of ASIO, boost is not required.

but with
Git:
make a folder for the project on C for example -> C:\SFNUL (RightMouse on folder -> Git Bash)
$ git clone https://github.com/binary1248/SFNUL.git

for C:\SFNUL\SFNUL (RightMouse on folder -> Git Bash)
$ git submodule update --init --recursive

he downloads a Asio Version with Boost. Perhaps i do something wrong, but i get a version with a few Boost
references.

Quote from: Nexus
but simply saying "I don't care about VS" while a significant part of people use it is too narrow-minded.
I understand him when he says that he dont want to support from state of the art old compilers. I hate
non-state-of-the-art things too. I dont realized it that microsoft's compiler are not comform to the latest
standard. But avoid Visual Studio is surely bad for the distribution of the product.

And using a new compiler for my whole project for example, brings new problems for sure. I drive good with
the native Visual Studio compiler and would rather change this library instead of changing my whole application to
a new compiler.

Quote from: Nexus
so the porting effort should be kept in reasonable bounds
I think too. There will not much to change.

Im a little bit sad about this. The library seems to be very awesome, like the developer of it.
At the moment its there are a lot of problems for me to implement it in my visual studio 2012 project (at the moment i try to get it run under visual studio 2013, to see where are the big difference of the state-of-the-art compiler and the latest native visual studio compiler),
but i hope it will be a matter of time until i get it run.

But the two task are standing in the room for me:

A) Making it working under Visual Studio 2013 native compiler(better for me would be Visual Studio 2012)
B) Removing all the Boost-Relations from ASIO (Or to figure out why he downloads not the standalone version)


Quote from: Nexus
Standards exist for a reason, and if you use non-standard tools/OS/whatever, then it is your responsibility to make it work for yourself.

But for the most the standard is microsoft. You are a minority to avoid it. I fully understand you, its your decession, its your library. But you exclude people that are not willing to make a lot of research and a lot of effort to get your library working.

Im bound on Visual Studio. Visual Studio is making all for me. I dont want to know more low-level compiling and other things around advanced compiling. I dont want to get more advanced in building my projects.

But i have huge interest of implement it. So i have to make workarounds. I think the most people who wants to use it, have to make workarounds.

And there i am and i have the another problem i have to solve, for that i need help from you.
I hope you can help me.


You've said that you use the Standalone Version of ASIO. But Git donwloads automaticly a version with Boost-references. What do i wrong?

Git:
make a folder for the project on C for example -> C:\SFNUL (RightMouse on folder -> Git Bash)
$ git clone https://github.com/binary1248/SFNUL.git

for C:\SFNUL\SFNUL (RightMouse on folder -> Git Bash)
$ git submodule init
$ git submodule update
Title: Re: SFNUL
Post by: binary1248 on December 23, 2013, 02:37:32 pm
but with
Git:
make a folder for the project on C for example -> C:\SFNUL (RightMouse on folder -> Git Bash)
$ git clone https://github.com/binary1248/SFNUL.git

for C:\SFNUL\SFNUL (RightMouse on folder -> Git Bash)
$ git submodule init
$ git submodule update

he downloads a Asio Version with Boost. Perhaps i do something wrong, but i get a version with a few Boost
references.
As stated in the README, git submodule update --init --recursive (which is what those 2 commands do, except recursive as well) pulls in all the required submodules. The maintainer of ASIO made it so that it interacts with boost, yes. But he also provided the possibility to use it without boost if you have a C++11 compiler, which is why the non-boost version is also known as the c++11 version. Sure, there will be references to boost in the files, but they are disabled with the defines that SFNUL defines for you.

At the moment its there are a lot of problems for me to implement it in my visual studio 2012 project,
but i hope it will be a matter of time until i get it run.
Let me guess... the other libraries you use are either precompiled for Visual Studio 2012 by rocket-scientist-grade developers, or simply don't work on other compilers because of broken non-portable code... Either way, this is exactly what I referred to in my long post above. If you want to rely on libraries that you can't port to another compiler whenever you wish, that is your choice. I am not going to backport SFNUL because of that, as it doesn't fit my philosophy. All the libraries I use are first of all cross-platform, and second of all, self-compiled so I know I can choose whatever compiler I want to use instead of letting libraries dictate that for me.

A) Making it working under Visual Studio 2013 native compiler(better for me would be Visual Studio 2012)
Writing a workaround for Visual Studio 2013 is simple if you understand why the error occurs. Less than 10 lines of extra code. Visual Studio 2012... good luck, you will need it.

B) Removing all the Boost-Relations from ASIO (Or to figure out why he downloads not the standalone version)
You really want to remove every single occurrence of the term "boost" from the asio code? As I already said, they do absolutely nothing with the provided defines, so removing them just so you feel better is a waste of time at best and might even break asio if you mess up somewhere. Don't touch the extlib code.

@binary1248
I will read it soon. A lot of text.
Must be the first time I've seen someone admitting they posted without reading prior posts. It is long yes, and maybe not all relevant to you, but really, in the time you took to write your post, you could have read it 3 times over.
Title: Re: SFNUL
Post by: TypeOverride on December 23, 2013, 03:01:48 pm
Git Bash:

for F:\GIT\PROJECTS\SNUFL (RM -> Git Bash)
$ git clone https://github.com/binary1248/SFNUL.git

for F:\GIT\PROJECTS\SNUFL\SFNUL (RM -> Git Bash)
$ git submodule update --init --recursive

This is the whole command. I have not much experience in Git. And had to to much research to get it working.
Now its easier yes.

"--init" and "--recursive" are the parameters?

---
Quote from: binary1248
Let me guess... the other libraries you use are either precompiled for Visual Studio 2012 by rocket-scientist-grade developers, or simply don't work on other compilers because of broken non-portable code
Is this a joke, that i dont understand? Sry im not a native english speaker. rocket-scientiest-grade developers i dont understand. My application depends on a lot
of submodules. The most written by me but there are two other good libraries i use. I study a little bit them. I can refactor every library, but this is not good, when newer versions come out of the libraries.
I have to make the changes again and again. Same with your library. But its better with one library, then making all the changes to 20 libraries, maybe.

I dont precompile libraries. I bind it directly in my solution, because maybe i make changes in that library. But then i talk to the developer most and ask him for making these changes i made for me in his library nativly.
But only if he wants it and he likes the new changes.

Quote from: binary1248
Writing a workaround for Visual Studio 2013 is simple

i will try it first. Than i give Visual Studio 2012 a chance.

Quote from: binary1248
You really want to remove every single occurrence of the term "boost" from the asio code?

No no, you told me that i initalized the git download wrong. I make a new try today to get the ASIO standalone version with your library.
Edit: I see i got it already and the library has cases for the C+11 standard.

Quote from: binary1248
Must be the first time I've seen someone admitting they posted without reading prior posts.

Ive readed it and updated the text. I thought you wouldnt read so fast my post.



Edit:
Quote
#if defined(ASIO_HAS_STD_ARRAY)
# include <array>
#else // defined(ASIO_HAS_STD_ARRAY)
# include <boost/array.hpp>
#endif // defined(ASIO_HAS_STD_ARRAY)

he chooses boost again.... (but its the ASIO library. So i have to see where the problem is why ASIO wants to use boost because http://www.cplusplus.com/reference/array/array/ should be there with Visual Studio 2013. Or not?)

Only for the completness , ive downloaded the project now in this way:
for C:\SFNUL
$ git clone https://github.com/binary1248/SFNUL.git

for C:\SFNUL\SFNUL
$ git submodule update --init --recursive

Edit2:
Dont missunderstand me. Im very thankfull for your help. I learn every day new things!

Edit3:
Ok i see i has to set ASIO_HAS_STD_ARRAY for getting the support, i think!
Visual Studio: properties -> c/C++ > Preprocessor -> Preprocessor Definitions ->
ASIO_HAS_STD_ARRAY
ASIO_HAS_STD_ADDRESSOF
ASIO_HAS_STD_SHARED_PTR
ASIO_HAS_VARIADIC_TEMPLATES
Title: Re: SFNUL
Post by: TypeOverride on February 22, 2014, 12:08:07 am
Of course it's frustrating that Microsoft is lacking behind, but simply saying "I don't care about VS" while a significant part of people use it is too narrow-minded. Saying "know your tool chains and just use gcc/clang" is even more so, considering that there can be other reasons (http://en.sfml-dev.org/forums/index.php?topic=13553.0) to choose one product over another, and a small part of people may even be bound to a specific IDE at work.

In my opinion, a library developer should at least try to support the most recent versions of all major compilers. Visual Studio 2013 has made a big step forward compared to 2012 concerning C++11 support, so the porting effort should be kept in reasonable bounds. That's just my point of view and the attitude I used while developing Thor -- and it's not a sole problem of VS, even if people like bashing Microsoft. I had to implement several workarounds for g++ and clang over time, for example I rewrote a significant part of TR1 random functionality, and I could not use lambda expressions in specific situation on clang because of a compiler bug.

Its a shame :( .  binary1248 is very resolut.

Current state:

BOTAN_DLL is marked red and causing an error. First of the 19497 errors is:

Error   1   error C3861: 'visibility': identifier not found   C:\SFNUL\extlibs\botan\include\botan\assert.h   18   1   sfnul

Edit:
First i recognize that "Replaced TropicSSL by Botan (20 days ago)".

Notice:
Versions 1.11.0 and later require a mostly-compliant C++11 compiler such as Clang 3.1 or GCC 4.7.

Thoughts: Perhaps first try the 1.10.0 to get to the goal !?

Edit:
-Botan compiling-
1) Download Pyhton >2.6 (http://www.python.org/downloads/)
2) open dos-prompt (shell)
3) <C:\SFNUL\extlibs\botan>c:\Python27\Python configure.py --cc=msvc

Than there is a "Makefile"-file now. (i see too there is a build.h file now that defines the BOTAN_DLL).
It getting better.

Thoughts: I think i have to go with "nmake" of Windows now to get a VisualStudio project !?

4) <C:\SFNUL\extlibs\botan>C:\"Program Files (x86)"\"Microsoft Visual Studio 12.0"\VC\bin\nmake

writing ERROR:
NMAKE : fatal error U1077: 'cl' return code '0x1' [/list]

next try --- goto 3)
3) <C:\SFNUL\extlibs\botan>c:\Python27\Python configure.py --cpu="i386"

4) <C:\SFNUL\extlibs\botan>C:\"Program Files (x86)"\"Microsoft Visual Studio 12.0"\VC\bin\nmake

writing ERROR:
makefile(1408) : fatal error U1001: syntax error : illegal character '.' in macro

Thoughts: Perhaps try to use "mingw" !?
Or going back to the Introduction -> - make install (as root) !?!? ->nmake ? but there is no makefile in the root. What is the CMake's module directory !? Im stuck.
Title: Re: SFNUL
Post by: zsbzsb on February 23, 2014, 08:32:09 pm
I can not believe that such a briliant piece of code is not buildable in windows. I dont want to believe it.

It is possible to build SFNUL using MSVC 2013, I just did it myself. Here is what it took for me to get it to build.


Also change the code in tls_channel.h

from:
      std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_write_cipher_states =
         { { 0, nullptr } };
      std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_read_cipher_states =
         { { 0, nullptr } };

to:
      std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_write_cipher_states;
      std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_read_cipher_states;

and the code in tls_channel.cpp

from:
Channel::Channel(std::function<void (const byte[], size_t)> output_fn,
                 std::function<void (const byte[], size_t)> data_cb,
                 std::function<void (Alert, const byte[], size_t)> alert_cb,
                 std::function<bool (const Session&)> handshake_cb,
                 Session_Manager& session_manager,
                 RandomNumberGenerator& rng,
                 size_t reserved_io_buffer_size) :
   m_handshake_cb(handshake_cb),
   m_data_cb(data_cb),
   m_alert_cb(alert_cb),
   m_output_fn(output_fn),
   m_rng(rng),
   m_session_manager(session_manager)
   {
   m_writebuf.reserve(reserved_io_buffer_size);
   m_readbuf.reserve(reserved_io_buffer_size);
   }

to:
Channel::Channel(std::function<void (const byte[], size_t)> output_fn,
                 std::function<void (const byte[], size_t)> data_cb,
                 std::function<void (Alert, const byte[], size_t)> alert_cb,
                 std::function<bool (const Session&)> handshake_cb,
                 Session_Manager& session_manager,
                 RandomNumberGenerator& rng,
                 size_t reserved_io_buffer_size) :
   m_handshake_cb(handshake_cb),
   m_data_cb(data_cb),
   m_alert_cb(alert_cb),
   m_output_fn(output_fn),
   m_rng(rng),
   m_session_manager(session_manager),
   m_write_cipher_states(),
   m_read_cipher_states()
   {
   m_write_cipher_states.insert({ 0, nullptr });
   m_read_cipher_states.insert({ 0, nullptr });
   m_writebuf.reserve(reserved_io_buffer_size);
   m_readbuf.reserve(reserved_io_buffer_size);
   }
Title: Re: SFNUL
Post by: wintertime on February 23, 2014, 09:16:00 pm
The old style replacement for noexcept (with a slightly different meaning) would be an empty "throw()" clause.
Title: Re: SFNUL
Post by: TypeOverride on February 24, 2014, 02:43:17 am
Thanks guys for helping me here. Sry to be such a rookie.

I hope i will get it working tomorrow. Only for checking if im doing it right:

root folder is C:\SFNUL

1) GIT for C:\SFNUL (Right Mouse -> Git Bash)
$ git clone https://github.com/binary1248/SFNUL.git

2) GIT for C:\SFNUL\SFNUL (Right Mouse -> Git Bash)
$ git submodule update --init --recursive

3) CMAKE (over DOS-prompt)
<E:\GIT\SFNUL\SFNUL> C:\"Program Files (x86)"\"CMake 2.8"\bin\cmake .

Is this all? What does he mean with

make install (as root)

on https://github.com/binary1248/SFNUL ?

Do i miss a step?
Title: Re: SFNUL
Post by: zsbzsb on February 24, 2014, 03:01:08 am
Quote
make install

Those are commands just for linux. After you generate a project file with cmake you then just need to follow what I posted above.
Title: Re: SFNUL
Post by: io on February 24, 2014, 03:36:45 am
Hey Binary,

I remember you mentioning this library a while back to me in pm. I'm still lurking around here, just low on time :(.  Wanted to pop in and just say congrats and thanks for releasing this! 

I'm sure it is quality and I look forward to using it when I have the time to get into game coding again :)

Title: Re: SFNUL
Post by: TypeOverride on February 24, 2014, 07:34:08 am
I can not believe that such a briliant piece of code is not buildable in windows. I dont want to believe it.

It is possible to build SFNUL using MSVC 2013, I just did it myself. Here is what it took for me to get it to build.

  • Add "BOTAN_DLL=" to the preprocessor
  • Add "NOEXCEPT=" to the preprocessor
  • Add "__func__=__FUNCTION__" to the preprocessor
  • Replace all instances of "noexcept" keyword with "NOEXCEPT" including in the external libraries
  • Add default constructors to the Botan::HTTP::Response and Botan::OCSP::Response classes

Thanks a lot. I am very close to the goal ^^.

i did every step and i get this error now (perhaps i did the constructor thing wrong?)


Error   4   error C2664: 'std::map<Botan::u16bit,std::shared_ptr<Botan::TLS::Connection_Cipher_State>,std::less<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>::map(std::initializer_list<std::pair<const _Kty,_Ty>>,const std::less<_Kty> &,const std::allocator<std::pair<const _Kty,_Ty>> &)' : cannot convert argument 1 from 'initializer-list' to 'const std::allocator<std::pair<const _Kty,_Ty>> &'   E:\GIT\SFNUL\SFNUL\extlibs\botan\include\botan\tls_channel.h   245   1   sfnul

the error occurs in tls_channel.h on
std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_write_cipher_states =
         { { 0, nullptr } };
      std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_read_cipher_states =
         { { 0, nullptr } };

what i did before was simple:

extlibs\botan\src\lib\utils\http_util\http_util.h
extlibs\botan\include\botan\http_util.h

Response() {}

and to

extlibs\botan\src\lib\cert\x509\http_util.h
extlibs\botan\include\botan\http_util.h

 Response() {}


Edit: Ok i compiled it success.

In tls_channel.h i did:
     std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_write_cipher_states; // =
        // { { 0, nullptr } };
     std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_read_cipher_states; // =
         //{ { 0, nullptr } };


And in tls_channel.cpp i did in the Channel::Channel(..) constructor

m_write_cipher_states.insert(std::pair<u16bit, std::shared_ptr<Connection_Cipher_State>>(0, nullptr));
   m_read_cipher_states.insert(std::pair<u16bit, std::shared_ptr<Connection_Cipher_State>>(0, nullptr));


I think its a compiler bug. With this it is compilable. Now i have to check if it is runnable at runtime.

Thanks guys!!!!!


Title: Re: SFNUL
Post by: Lolilolight on February 24, 2014, 10:15:50 am
Hi!

Which networking libraries did you use for your project ?

Personally I only use Openssl for the networking and it works well on windows. (Except the extensions for the SSL certificates which give me compilation errors so I generate random keys and I put them into a certificate automatically in the library because I just need the hashing keys and not all the certificates stuff and verifications.

I don't think you need to do all verifications that the SSL protocol does to have a secure network communication.

For the rest of the functionnalities it doesn't mind for me to use the selectors and the sfml base classes, it's what I use for my project but, I'm curious so I would like to know how do you proceed to do assynchroneous communication, did you use a thread ?

In my project I just have a server and a client class which use a thread to recieve messages and put them into a stack of another class, and the user can process the datas when he want.

And I use a selector in this thread.

I have also a mutex to lock the socket when the server or the client receive or send a packet to avoid to have concurrent thread access on the socket because the messages are send inthe main thread and are received in another thread. (I was having hard to find this bug because I've forgot to use the mutex)

Do you also process like that or, do you have another system ?

PS: I'll also put that in my framework because I'm pised off to use the same code for all of my projects.




Title: Re: SFNUL
Post by: eXpl0it3r on February 24, 2014, 11:08:44 am
Why don't you simply look at the source code? Or well at least read the README?

Quote from: README on GitHub
Dependencies:
 - ASIO (standalone C++11 version) provided in extlibs as a submodule
 - Botan provided in extlibs as a submodule
 - http-parser provided in extlibs as a submodule
 - SFML 2.x for the optional SFML synchronization example (http://sfml-dev.org/)

ASIO is used for the basic networking. Botan is used to TLS. For details look at the source code (https://github.com/binary1248/SFNUL).
Title: Re: SFNUL
Post by: Lolilolight on February 24, 2014, 12:01:57 pm
:o

I don't know this library : Botan.

So I've used openssl directly.

If only I've known that such a library exist..., but too late now. ^^ (I've already rewritten this with openssl for the encryption)







Title: Re: SFNUL
Post by: TypeOverride on February 24, 2014, 02:39:49 pm
I compiled it success under Visual Studio 2013.

After each step "zsbzsb" gave me (Thanks! Thanks! Thanks!).
I had todo last one step. I think its a compiler bug workaround here.

------
In tls_channel.h i did:
     std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_write_cipher_states; // =
        // { { 0, nullptr } };
     std::map<u16bit, std::shared_ptr<Connection_Cipher_State>> m_read_cipher_states; // =
         //{ { 0, nullptr } };

And in tls_channel.cpp i did in the Channel::Channel(..) constructor
     m_write_cipher_states.insert(std::pair<u16bit, std::shared_ptr<Connection_Cipher_State>>(0, nullptr));
     m_read_cipher_states.insert(std::pair<u16bit, std::shared_ptr<Connection_Cipher_State>>(0, nullptr));
------

Now i have to check if it is all running at runtime.

Thanks guys!!!!!
Title: Re: SFNUL
Post by: zsbzsb on February 24, 2014, 02:47:40 pm
Sorry about that TypeOverride, I had to do the same thing and forgot to mention it.  ;)

Also I updated my above post.  :)
Title: Re: SFNUL
Post by: TypeOverride on February 24, 2014, 03:59:52 pm
Sorry about that TypeOverride, I had to do the same thing and forgot to mention it.  ;)

Also I updated my above post.  :)

Thanks alot ! Without your help i would be lost in code.
Title: Re: SFNUL
Post by: TypeOverride on April 10, 2014, 02:21:53 am
So ive implemented this library for a prototype to test the features i need to making a working solution for my game.

At the moment i see a problem when try to remove a synchronized object that is not the last object that was pushed to the list. Its not working proper.

There is no way to use pointers for the synchronizer, so i have to carry around values.

When using _synchronizerServer.CreateObject<Entity>();
Also, the copy constructor will be called 2 times. With a pointer it shouldnt be such a cost problem.

But the main problem is that Synchroned Objects are values which i get over the CreateObject-Method where i cant really make a reference from, beside the list where the synchronized objects stored.

The memory allocation is changing automaticly when objects are removed form the STL containers, i guess.
 
I cant see how the STL container-classes manage the allocation of memory, but i see that something is wrong when i try to make something like:

_entities.push_back(_synchronizerServer->CreateObject<Entity>());
Entity& entityA = _entities.back();

So when i try to use entityA later, after i removed some other objects out of the _entities-list, it will shows that the reference is not valid anymore.

I think without modifying the synchronizer it wont work. I need pointers. Interrupt me, when im wrong, but is see no other way for the problem.
 
So ive manipulated the synchronizer.inl file like this and use now _synchronizerServer->CreateObject2<Entity>()

template<typename T, typename... Args>
T* SynchronizerServer::CreateObject2(Args&&... args) {
        T* object = new T(std::forward<Args>(args)...);

        object->SetSynchronizer(this);

        return object;
}

And now it works for me like it should.

I see two architecture hurdles,
A) Synchronization of sub-syncObjects of a syncObject.
B) Different views. At the moment i see that all syncObjects are there for synchronize all clients with the same objects, but why should objects be synchronized with clients/players where the object is currently dont visible. So i need more than one synchronizer (for each client (player)) that only synchronize the visible objects for a client.

So at the end it cant be solved in the way that the synchronizer handles the creation of the SyncObjects like it do with the CreateObject-Method.

With this way there is for each synchronizer a represenation of a SyncObject on Server-Side. So i have to remove the CreateObject-Method and give the synchronizer directly the SyncObject to make it possible to share the syncObject with all synchronizer (for each client) on the server.
Title: Re: SFNUL
Post by: Turbine on April 29, 2014, 01:29:59 am
This doesn't compile for me, I get a heap of errors (MinGW 4.8.2):

Quote
||=== Build: all in SFNUL (compiler: GNU GCC Compiler) ===|
D:\projects\sfnul\extlibs\botan\include\botan\scan_name.h|97|error: 'mutex' in namespace 'std' does not name a type|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|65|error: 'mutex' in namespace 'std' does not name a type|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|178|error: 'mutex' is not a member of 'std'|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|178|error: 'mutex' is not a member of 'std'|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|178|error: template argument 1 is invalid|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|178|error: invalid type in declaration before '(' token|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|178|error: 's_alias_map_mutex' was not declared in this scope|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|186|error: 'mutex' is not a member of 'std'|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|186|error: 'mutex' is not a member of 'std'|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|186|error: template argument 1 is invalid|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|186|error: invalid type in declaration before '(' token|
D:\projects\sfnul\extlibs\botan\src\lib\algo_base\scan_name.cpp|186|error: 's_alias_map_mutex' was not declared in this scope|
CMakeFiles\sfnul.dir\build.make|81|recipe for target 'CMakeFiles/sfnul.dir/extlibs/botan/src/lib/algo_base/scan_name.cpp.obj' failed|
CMakeFiles\Makefile2|62|recipe for target 'CMakeFiles/sfnul.dir/all' failed|
D:\projects\sfnul_bin\Makefile|115|recipe for target 'all' failed|
||=== Build failed: 15 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
Title: Re: SFNUL
Post by: binary1248 on April 29, 2014, 01:39:27 am
This doesn't compile for me, I get a heap of errors (MinGW 4.8.2)
What is the full version of your MinGW g++? You can find out by issuing the command g++ -v in the MinGW console. Post it here.
Title: Re: SFNUL
Post by: Turbine on April 29, 2014, 07:17:55 am
This doesn't compile for me, I get a heap of errors (MinGW 4.8.2)
What is the full version of your MinGW g++? You can find out by issuing the command g++ -v in the MinGW console. Post it here.

Here it is, I'll try in another release of MinGW.

Quote
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=C:/mingw2/bin/../libexec/gcc/x86_64-w64-mingw32/4.8.2/lto-wr
apper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-4.8.2/configure --host=x86_64-w64-mingw32 --bu
ild=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysr
oot=/c/mingw482/x86_64-482-win32-seh-rt_v3-rev3/mingw64 --with-gxx-include-dir=/
mingw64/x86_64-w64-mingw32/include/c++ --enable-shared --enable-static --disable
-multilib --enable-languages=ada,c,c++,fortran,objc,obj-c++,lto --enable-libstdc
xx-time=yes --enable-threads=win32 --enable-libgomp --enable-libatomic --enable-
lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --
enable-version-specific-runtime-libs --disable-isl-version-check --disable-cloog
-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootst
rap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --di
sable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 -
-with-libiconv --with-system-zlib --with-gmp=/c/mingw482/prerequisites/x86_64-w6
4-mingw32-static --with-mpfr=/c/mingw482/prerequisites/x86_64-w64-mingw32-static
 --with-mpc=/c/mingw482/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mi
ngw482/prerequisites/x86_64-w64-mingw32-static --with-cloog=/c/mingw482/prerequi
sites/x86_64-w64-mingw32-static --enable-cloog-backend=isl --with-pkgversion='x8
6_64-win32-seh-rev3, Built by MinGW-W64 project' --with-bugurl=http://sourceforg
e.net/projects/mingw-w64 CFLAGS='-O2 -pipe -I/c/mingw482/x86_64-482-win32-seh-rt
_v3-rev3/mingw64/opt/include -I/c/mingw482/prerequisites/x86_64-zlib-static/incl
ude -I/c/mingw482/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2
 -pipe -I/c/mingw482/x86_64-482-win32-seh-rt_v3-rev3/mingw64/opt/include -I/c/mi
ngw482/prerequisites/x86_64-zlib-static/include -I/c/mingw482/prerequisites/x86_
64-w64-mingw32-static/include' CPPFLAGS= LDFLAGS='-pipe -L/c/mingw482/x86_64-482
-win32-seh-rt_v3-rev3/mingw64/opt/lib -L/c/mingw482/prerequisites/x86_64-zlib-st
atic/lib -L/c/mingw482/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: win32
gcc version 4.8.2 (x86_64-win32-seh-rev3, Built by MinGW-W64 project)

MinGW 4.8.1 x86 is also acting the same.
Title: Re: SFNUL
Post by: binary1248 on April 29, 2014, 10:34:51 am
Can you compile this?
#include <mutex>

int main()
{
    std::mutex m;
}
Title: Re: SFNUL
Post by: Turbine on April 29, 2014, 11:43:26 am
Can you compile this?
#include <mutex>

int main()
{
    std::mutex m;
}

It isn't working like this either. I wonder why std::mutex it's not being included with MinGW.
Title: Re: SFNUL
Post by: binary1248 on April 29, 2014, 02:23:26 pm
Well... your installation is screwed up. You are probably using the old headers that had experimental/broken threading support. Maybe if you delete the whole folder and replace it with a fresh install it will work.
Title: Re: SFNUL
Post by: Turbine on April 30, 2014, 12:58:46 am
Well... your installation is screwed up. You are probably using the old headers that had experimental/broken threading support. Maybe if you delete the whole folder and replace it with a fresh install it will work.

[Edit]
It seems that threading in MinGW is currently experimental and in development. MinGW-builds worked whereas the normal build from mingw.org did not include the library.
Title: Re: SFNUL
Post by: MorleyDev on April 30, 2014, 01:43:54 am
It depends on the threading model used by the MinGW version I believe. If it's compiled to use the Win32 threading model, it does not support std::thread, whilst the Posix threading model uses winpthread to provide threading support.
Title: Re: SFNUL
Post by: zeno15 on December 09, 2014, 03:45:19 am
Apologies for resurrecting this thread but it was the only relevant one I could find. 

I'm attempting to build SFNUL with Visual Studio 2013, and have run into issues, if anyone had any ideas that'd be greatly appreciated.

Firstly when you say to add preproccessor definitions, is that after cmake has made the visual studio solutions, or before?  And if it is after, where do I actually add them, I've looked and the place where I would normally define SFML_STATIC etc isn't present, unless I'm missing something.

Thanks for your time guys.
Title: AW: SFNUL
Post by: eXpl0it3r on December 09, 2014, 07:29:24 am
When building SFNUL, CMake will set everything properly, as long as you check/uncheck the right settings.
Only once you try to link everything into your final application, you'll need to set pre-processor flags when linking statically.
Title: Re: SFNUL
Post by: binary1248 on December 12, 2014, 12:52:12 am
So... what exactly would this tutorial contain? You do essentially the same as you would do if you built SFML, so you can just refer to the SFML tutorial on building with CMake. If you are already familiar with that but still insist that SFNUL should have it's own pictorial step-by-step tutorial just so you don't have to think a bit, then maybe you should stick to SFML's networking. You simply can't appreciate what SFNUL has to offer if you aren't willing to explore a bit yourself.

And by the way... people do use SFNUL already. Certain kinds of people... The people who I consider worth writing a library for.
Title: Re: SFNUL
Post by: StormWingDelta on February 08, 2015, 06:02:07 pm
hmm this might be useful when I get around to the networking part of my game.


Meantime out of curiosity.  Are you planning on implementing UDP assuming you haven't already.  I know there aren't many changes between TCP and UDP but just wondering on that note. :)
Title: Re: SFNUL
Post by: binary1248 on February 08, 2015, 06:09:50 pm
Are you planning on implementing UDP assuming you haven't already. I know there aren't many changes between TCP and UDP but just wondering on that note.
What do you mean with "implementing UDP"? UDP sockets are already implemented and usable (https://github.com/binary1248/SFNUL/blob/master/include/SFNUL/UdpSocket.hpp).
Title: Re: SFNUL
Post by: StormWingDelta on February 08, 2015, 06:11:33 pm
Are you planning on implementing UDP assuming you haven't already. I know there aren't many changes between TCP and UDP but just wondering on that note.
What do you mean with "implementing UDP"? UDP sockets are already implemented and usable (https://github.com/binary1248/SFNUL/blob/master/include/SFNUL/UdpSocket.hpp).

oops, guess it would help if I wouldn't glaze over things when looking for them. :(
Title: Re: SFNUL
Post by: Zax37 on April 12, 2015, 10:01:09 am
Hey there,
I'm really fighting hard to build SFNUL and see all that awesomeness, but it's just not letting me.
First of all - git submodule isn't working for me, so I cloned the dependencies by myself.
Secondly - had some problems with mingw headers, but found patch which fixed it.
Now I'm already at 89% and it's throwing errors at my face again:

E:\Projects\SFNUL\src\SFNUL\NetworkResource.cpp:35:10: error: invalid use of tem
plate-name 'asio::strand' without an argument list
  mutable asio::strand strand;
          ^
E:\Projects\SFNUL\src\SFNUL\NetworkResource.cpp: In constructor 'sfn::NetworkRes
ource::NetworkResourceImpl::NetworkResourceImpl()':
E:\Projects\SFNUL\src\SFNUL\NetworkResource.cpp:26:3: error: class 'sfn::Network
Resource::NetworkResourceImpl' does not have any field named 'strand'
   strand{ *io_service }
   ^
E:\Projects\SFNUL\src\SFNUL\NetworkResource.cpp: In member function 'void* sfn::
NetworkResource::GetStrand() const':
E:\Projects\SFNUL\src\SFNUL\NetworkResource.cpp:51:18: error: 'class sfn::Networ
kResource::NetworkResourceImpl' has no member named 'strand'
  return &m_impl->strand;
                  ^
E:\Projects\SFNUL\src\SFNUL\NetworkResource.cpp:52:1: warning: control reaches e
nd of non-void function [-Wreturn-type]
 }
 ^
CMakeFiles\sfnul.dir\build.make:4614: recipe for target 'CMakeFiles/sfnul.dir/sr
c/SFNUL/NetworkResource.cpp.obj' failed
mingw32-make[2]: *** [CMakeFiles/sfnul.dir/src/SFNUL/NetworkResource.cpp.obj] Er
ror 1
CMakeFiles\Makefile2:59: recipe for target 'CMakeFiles/sfnul.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/sfnul.dir/all] Error 2
Makefile:115: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

I'm using TDM GCC 4.9.2 DW2 and I successfully built SFML, SFGUI and all other goodness under it, so what's wrong with SFNUL? Also, doesn't that whole "asio" need to be built? It's not included in CMakeLists. Thanks!
Title: Re: SFNUL
Post by: binary1248 on April 12, 2015, 10:48:16 am
First of all - git submodule isn't working for me, so I cloned the dependencies by myself.
Instead of working around a problem, you should really try fixing it. ;)

The submodule declarations contain more than just a repository name/source, they also contain branches/versions. Indeed, SFNUL doesn't use the master version of ASIO, so whatever you cloned probably doesn't work out of the box like the submodule does.

Secondly - had some problems with mingw headers, but found patch which fixed it.
This sounds even more troubling... What kind of a patch was this? And what did/didn't work? If anything doesn't work, at least ask for assistance before applying random patches to the base installation. They might end up breaking more things than they fix.

I'm using TDM GCC 4.9.2 DW2 and I successfully built SFML, SFGUI and all other goodness under it, so what's wrong with SFNUL?
There is nothing wrong with SFNUL, but there are many things wrong with your development environment as stated above. ;)

Also, doesn't that whole "asio" need to be built? It's not included in CMakeLists.
No. Using the submodule that I picked out, ASIO can be used header-only. I have no idea what repository/branch you are on right now, but I can't guarantee that something you cloned yourself will work with SFNUL.

Rewind (reinstall MinGW if necessary), and go back to the "git submodule doesn't work for me" stage and provide some error information. That is a starting point that we will be able to work with.
Title: Re: SFNUL
Post by: Zax37 on April 12, 2015, 11:08:16 am
Instead of working around a problem, you should really try fixing it. ;)
Yeah, I'd love to, just couldn't find any solution, so I just sadly accepted the fact that windows version of github has its charms ;p error is:

fatal: 'submodule' appears to be a git command, but we were not
able to execute it. Maybe git-submodule is broken?

I've found some questions about it, no solution though.

This sounds even more troubling... What kind of a patch was this? And what did/didn't work? If anything doesn't work, at least ask for assistance before applying random patches to the base installation. They might end up breaking more things than they fix.
http://tehsausage.com/mingw-to-string
Well, it seems to have worked for me :P

There is nothing wrong with SFNUL, but there are many things wrong with your development environment as stated above. ;)
Hahah yeah I know, I was just messing with You :P SFML handled it though!

Rewind (reinstall MinGW if necessary), and go back to the "git submodule doesn't work for me" stage and provide some error information. That is a starting point that we will be able to work with.
Yeah, I'll start with reinstalling MinGW and/or building with another version.
Thanks for the support ;)
Title: Re: SFNUL
Post by: binary1248 on April 12, 2015, 11:26:08 am
Yeah, I'd love to, just couldn't find any solution, so I just sadly accepted the fact that windows version of github has its charms

fatal: 'submodule' appears to be a git command, but we were not
able to execute it. Maybe git-submodule is broken?

I've found some questions about it, no solution though.
The reason is simple: Because there is no solution. :P Seriously though, don't use GitHub's program, whatever it's called. If you even bother with git, use it directly. You won't end up with strange problems such as these.

http://tehsausage.com/mingw-to-string
Well, it seems to have worked for me
You do realize that that "patch" is for 4.7.0 right? As in... the version that might not have fully supported C++11 yet? Since you are using 4.9.2, you are doing nothing else but breaking a working installation by applying random patches such as these. Just... don't do it. Never ever modify your toolchain installation. If something doesn't work, it has either been fixed or implemented in a newer version of the toolchain, so upgrading it is the only sane solution.

Yeah, I'll start with reinstalling MinGW and/or building with another version.
SFNUL builds on MinGW 4.9.2, there is no reason to try with another version. Like I said, solve the git problem first and work from there.
Title: Re: SFNUL
Post by: eXpl0it3r on April 12, 2015, 12:03:36 pm
For the lazy people here's a simple batch file that will build SFNUL as static libs in debug and release mode.

Prerequisites:
git clone https://github.com/binary1248/SFNUL.git
cd SFNUL
git submodule update --init --recursive
mkdir build
cd build
cmake -G"MinGW Makefiles" -DSFNUL_USE_STD_THREAD=TRUE -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=Debug -DSFNUL_BUILD_EXAMPLES=FALSE ..\
mingw32-make install -j8
cmake -G"MinGW Makefiles" -DSFNUL_USE_STD_THREAD=TRUE -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=Release -DSFNUL_BUILD_EXAMPLES=FALSE ..\
mingw32-make install -j8

The builds can finally be found in the SFNUL/install directory.
Title: Re: SFNUL
Post by: Zax37 on April 12, 2015, 03:05:06 pm
I uninstalled GitHub, installed Git and everything worked as charm!

Thank You both, gentlemen! :)
Title: Re: SFNUL
Post by: spacechase0 on April 25, 2015, 06:36:24 am
While this might just be because I'm oblivious sometimes, I think a warning here (https://github.com/binary1248/SFNUL/blob/master/src/SFNUL/TcpSocket.cpp#L380) would be useful. I was using HTTPClient and I spent a couple hours trying to figure out why the server was "ignoring" my request (uploading multiple MB files) and just got stuck forever. (Or did I miss a way to check for non-HTTP errors within HTTPClient/HTTPResponse?)

I'm still having some other issues with large-ish requests, but I want to try another thing or two for that.
Title: Re: SFNUL
Post by: binary1248 on April 25, 2015, 10:31:24 am
https://github.com/binary1248/SFNUL/blob/7e1f198dcc0445746a1a5aea7d350412aad27c92/include/SFNUL/Utility.hpp#L29
https://github.com/binary1248/SFNUL/blob/7e1f198dcc0445746a1a5aea7d350412aad27c92/examples/TestClient.cpp#L341
https://github.com/binary1248/SFNUL/blob/7e1f198dcc0445746a1a5aea7d350412aad27c92/examples/TestServer.cpp#L391
;D

The "problem" if you can even call it that, is that there currently is no "general documentation" location. All documentation is contextual since it is written as part of the header files. I didn't feel like adding a note about the block size setting to every single class since I figured anybody willing to use the library would eventually stumble into it themselves. I guess you eventually did ;D.
Title: ReĀ : SFNUL
Post by: Peb on August 31, 2015, 12:42:32 pm
Hello, and congratz for this amazing library !  :)

Unfortunately I get a post-compilation problem (linking), when I compile my project using your library.

My version of gcc is : gcc version 4.9.2 (x86_64-posix-seh-rev3, Built by MinGW-W64 project)

Here is the report :

Quote
[100%] Building CXX object CMakeFiles/server.dir/code/Server.cpp.obj
Linking CXX executable ..\bin\server.exe
D:\C++\SFNUL\lib\libsfnul-s.a(TcpListener.cpp.obj):TcpListener.cpp:(.text$_ZN3sfn11TcpListener15TcpListenerImpl13AcceptHandlerERKSt10error_codeSt10shared_ptrIN4asio19basic_stream_socketINS6_2ip3tcpENS6_21stream_socket_serviceIS9_EEEEE[_ZN3sfn11TcpListener15TcpListenerImpl13AcceptHandlerERKSt10error_codeSt10shared_ptrIN4asio19basic_stream_socketINS6_2ip3tcpENS6_21stream_socket_serviceIS9_EEEEE]+0x8cb): undefined reference to `AcceptEx'
D:\C++\SFNUL\lib\libsfnul-s.a(TcpListener.cpp.obj):TcpListener.cpp:(.text$_ZN4asio6detail25win_iocp_socket_accept_opINS_12basic_socketINS_2ip3tcpENS_21stream_socket_serviceIS4_EEEES4_NS0_15wrapped_handlerINS_10io_service6strandESt5_BindIFZN3sfn11TcpListener15TcpListenerImpl13AcceptHandlerERKSt10error_codeSt10shared_ptrINS_19basic_stream_socketIS4_S6_EEEEUlSt8weak_ptrISD_ESH_SL_E_SN_St12_PlaceholderILi1EESL_EEEEE11do_completeEPNS0_19win_iocp_io_serviceEPNS0_18win_iocp_operationESH_y[_ZN4asio6detail25win_iocp_socket_accept_opINS_12basic_socketINS_2ip3tcpENS_21stream_socket_serviceIS4_EEEES4_NS0_15wrapped_handlerINS_10io_service6strandESt5_BindIFZN3sfn11TcpListener15TcpListenerImpl13AcceptHandlerERKSt10error_codeSt10shared_ptrINS_19basic_stream_socketIS4_S6_EEEEUlSt8weak_ptrISD_ESH_SL_E_SN_St12_PlaceholderILi1EESL_EEEEE11do_completeEPNS0_19win_iocp_io_serviceEPNS0_18win_iocp_operationESH_y]+0xfd): undefined reference to `GetAcceptExSockaddrs'
D:\C++\SFNUL\lib\libsfnul-s.a(TcpListener.cpp.obj):TcpListener.cpp:(.text$_ZN4asio6detail25win_iocp_socket_accept_opINS_12basic_socketINS_2ip3tcpENS_21stream_socket_serviceIS4_EEEES4_NS0_15wrapped_handlerINS_10io_service6strandESt5_BindIFZN3sfn11TcpListener15TcpListenerImpl13AcceptHandlerERKSt10error_codeSt10shared_ptrINS_19basic_stream_socketIS4_S6_EEEEUlSt8weak_ptrISD_ESH_SL_E_SN_St12_PlaceholderILi1EESL_EEEEE11do_completeEPNS0_19win_iocp_io_serviceEPNS0_18win_iocp_operationESH_y[_ZN4asio6detail25win_iocp_socket_accept_opINS_12basic_socketINS_2ip3tcpENS_21stream_socket_serviceIS4_EEEES4_NS0_15wrapped_handlerINS_10io_service6strandESt5_BindIFZN3sfn11TcpListener15TcpListenerImpl13AcceptHandlerERKSt10error_codeSt10shared_ptrINS_19basic_stream_socketIS4_S6_EEEEUlSt8weak_ptrISD_ESH_SL_E_SN_St12_PlaceholderILi1EESL_EEEEE11do_completeEPNS0_19win_iocp_io_serviceEPNS0_18win_iocp_operationESH_y]+0x369): undefined reference to `AcceptEx'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\server.dir\build.make:191: recipe for target '../bin/server.exe' failed
mingw32-make[2]: *** [../bin/server.exe] Error 1
CMakeFiles\Makefile2:59: recipe for target 'CMakeFiles/server.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/server.dir/all] Error 2
makefile:75: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

I'm using the static version of SFNUL compiled with the script found on a previous post (the one with Git).

Here is my CMakeLists.txt :

Quote
cmake_minimum_required( VERSION 2.8 )
set( ROOTDIR ${CMAKE_SOURCE_DIR} )
set( CMAKE_MODULE_PATH ${ROOTDIR}/cmake/modules )
set( EXECUTABLE_OUTPUT_PATH ${ROOTDIR}/bin )
add_definitions( -static-libgcc -static-libstdc++ -Wfatal-errors -std=c++11 -fpermissive -municode )
file( GLOB_RECURSE source_files code/* )
set( SFNUL_STATIC_LIBRARIES TRUE )
find_package( SFNUL REQUIRED )
include_directories( ${ROOTDIR}/code ${SFNUL_INCLUDE_DIR} )
add_executable( server ${source_files} code/Server.cpp )
target_link_libraries( server ${SFNUL_LIBRARY} ${SFNUL_DEPENDENCIES} )

What am I doing wrong ?
Title: Re: SFNUL
Post by: binary1248 on August 31, 2015, 05:02:37 pm
You aren't doing anything wrong. ;D

I added the missing mswsock library to FindSFNUL.cmake. If you grab the newest revision it should be fixed there.
Title: Re: SFNUL
Post by: Peb on August 31, 2015, 05:27:51 pm
It's working now, thanks man !  :D
Title: Re: SFNUL
Post by: silverweed on September 02, 2015, 11:38:38 am
This looks really cool...makes me want to add multiplayer to the game I'm making just to try this library  ::)
Title: Re: SFNUL
Post by: AlexxanderX on December 16, 2015, 09:35:10 pm
Nice library. I decided to use SFNUL in my new tableboard multiplayer mini game, but I need some help. I firstly used SFML and then decided to use SFNUL because of the relief of code the library offer. In my LAN server overview window I used sf::UdpSocket with sf::AnyPort to send a package to all servers on network using sf::IpAddress::Broadcast and the port of the server, then the server would send back the a package so the client would know that at that ip is a server. Now that I switched to SFNUL I don't know how to do same thing. The Bind() function require a ip address and a port, not just the port and also how to send a message to the network because I can't find a function to get the broadcast ip address( EDIT: I think it is 0.0.0.0).
Title: SFNUL
Post by: eXpl0it3r on December 16, 2015, 09:49:23 pm
You might want to read up a bit on networking and/or look at the SFML implementation. ;)
There are official UDP broadcast IP addresses.
Title: Re: SFNUL
Post by: binary1248 on December 16, 2015, 10:00:33 pm
You can bind to whatever address you want to bind to. 0.0.0.0 is AnyAddress in SFML, but this naming can be a bit ambiguous because it doesn't just select a single address out of multiple possible addresses, it actually binds to all addresses.

As for broadcasting, like eXpl0it3r said, you need to know what you actually want to achieve. There are many different ways to broadcast. Depending on your network parameters you also need to select the proper broadcast domain. Once you have the broadcast address, it is just a matter of sending data to that address. It doesn't target a single host in the usual manner but a whole domain.
Title: Re: SFNUL
Post by: AlexxanderX on December 17, 2015, 11:39:42 am
After I read on internet on the broadcast ip address and how to calculate it I tested on the precalculated broadcast ip address of my ip address and worked :D . Now the question is: what is the best way to get the local ip and mask? Should I include and use asio or is a better way? ( If asio is the way, should use the version that come with SFNUL? I found in the SFNUL's cmake file that the include path is included but leave out the sources, or maybe he is just a dependency of a dependency).
Title: Re: SFNUL
Post by: binary1248 on December 17, 2015, 12:31:55 pm
There is no best way to get all of your local interface addresses, there is no portable way at all, not even with ASIO. Applications normally either just bind to 0.0.0.0 by default, or let the user specify an address to bind on (because they should normally know this themselves). Any way to programatically find out all your interface addresses would be very platform specific and have to be implemented on each platform you want to support.
Title: Re: SFNUL
Post by: AlexxanderX on December 17, 2015, 03:18:04 pm
Thanks for help. One more question: how can I debug the code: I want to say that SFML would return a Status and I would check if the command executed was successfully or not and from what I see in SFNUL the functions return nothing( maybe because they run in thread and do not execute immediately).
Title: Re: SFNUL
Post by: Nexus on December 17, 2015, 03:57:21 pm
Any way to programatically find out all your interface addresses would be very platform specific and have to be implemented on each platform you want to support.
It may be that this is one of the problems that everybody has to solve again in C++, but for example in Java (https://docs.oracle.com/javase/tutorial/networking/nifs/) such functionality is part of the standard library. One could also have a look at how they do it.
Title: Re: SFNUL
Post by: binary1248 on December 17, 2015, 05:20:11 pm
As usual, it is not a question of whether it can be done, but who would actually use it. We all know that Java likes to overestimate/over-engineer the feature set of its library, resulting in 98% of it never being used. We really shouldn't consider it as an example of what should be available in C/C++ ;). The languages have completely different philosophies, and I prefer C++'s one more.

If you look at most of the daemons running on Unix systems (where C/C++ and the Berkeley socket API originated), you will notice that they don't try to detect your interfaces and offer you a choice of which addresses to listen/bind to. This is the task of other user-space tools that serve that specific purpose. Most of the time, you would have to configure which addresses you want to listen on (completely disregarding what interface they correspond to). The reason why there isn't an API to iterate over all the interfaces is probably because nobody would end up using it.

Instead of asking how to iterate over all interfaces, one should just take a step back and first ask what one wants to achieve by doing so. I really can't think of any use case where it would make sense.
Title: Re: SFNUL
Post by: Xotraz on December 18, 2015, 08:33:58 pm
I am concerned with performance (maybe too much).

What I imagined for my 2D online card game was that a player need an image and an interface. So I used little packets to control Animation (ID of animation, name of animation, number of times to play, position). (and another packet class for sounds)

I think this could handle all kinds of game. But in SFML books or this library people seem to "serialize" the world and send it.
Am I missing something that make your way much better ?

PS : I am a big fan of your works thought.  :D
Title: Re: SFNUL
Post by: binary1248 on December 18, 2015, 10:11:31 pm
In SFNUL you get serialization for free. I guess you could say that objects are "self-serializing". Of course you will have to use the proper types as shown in the examples because you can't change the behaviour of any built-in type or STL containers. The SFNUL types were designed to mimic/proxy the built-in types as well as STL containers, so the conversion from "standard" objects to SFNUL objects should be really simple in most scenarios.