GithubHelp home page GithubHelp logo

protovision / socketstream Goto Github PK

View Code? Open in Web Editor NEW
9.0 4.0 2.0 39 KB

An std::iostream derived C++ class for synchronous socket I/O.

C++ 100.00%
socket stream cpp iostream streambuf io network tcp-client bsd-sockets

socketstream's Introduction

socketstream is a header-only library for socket I/O.

The following classes are defined:

	swoope::socketbuf:
		An std::streambuf derived class that implements a raw socket
		device.

	swoope::socketstream: 
		An std::iostream derived class that implements high-level 
		stream input/output on a swoope::socketbuf.

socketstream works with POSIX and Windows. Compatible with C++03,
move semantics enabled for C++11.

Author: Mark Swoope
Date: July 2017

Compiling and running the examples:

If you are using the Visual C++ compiler, the commands:

cl /EHsc server_example.cc ws2_32.lib
cl /EHsc client_example.cc ws2_32.lib

should compile the example programs when issued from a Developer Command Prompt for VS.

If you are using the MinGW compiler, then the commands would be:

g++ -D _WIN32 -o server_example.exe server_example.cc -lws2_32
g++ -D _WIN32 -o client_example.exe client_example.cc -lws2_32

For Linux and Mac, the commands are:

g++ -o server_example.exe server_example.cc
g++ -o client_example.exe client_example.cc

(.exe extention is optional for Linux and Mac)

After compiling successfully, to test the programs first run:

server_example.exe 6789

in one terminal window, then run

client_example.exe localhost 6789

In another terminal window and begin entering lines of text into the client terminal window to see the server echo them back.

socketstream's People

Contributors

protovision avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

socketstream's Issues

Not working on Windows

Hello! I cloned this repo on my Windows 10 laptop, and I tried running the server and client examples, but it doesn't seem to compile. It gives errors from the winsock_native_socket_traits.hh file, all along the lines of error: '::getaddrinfo' was not declared in this scope. The same goes for ::freeaddrinfo and ::getnameinfo. Is there a way to fix this? Thanks!

License?

Hello! Would you consider adding an explicit license to this class? It is quite nice and I'd love to have explicit permission to actually use it.

May I suggest the Apache license if you don't have a preference.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.