# Introduction

1. Intro
2. Requirements
3. Installing
4. Library usage
5. Cross compiling SocketW to W32
6. Using MS VisC/C++ or Borland CC
7. Misc.

This is from the SocketW README file:

#

##

##

##

##

##

##

##

    C++ Socket Wrapper (SocketW)
    www.digitalfanatics.org/cal/socketw/index.html
    www.etek.chalmers.se/~e8cal1/socketw/index.html

    Author: Anders Lindström - Email: cal[at]swipnet[dot]se (replace [at] with @ and [dot] with .)

    1. Intro
    SocketW is a cross platform (Linux/FreeBSD/Unix/Win32) streaming socket C++
    library designed to be easy to use. It supports Unix sockets and TCP/IP sockets
    with optional SSL/TLS (OpenSSL) support. SocketW allows you to write portable
    and secure network applications quickly without needing to spend time learning
    low-level system functions or reading OpenSSL manuals.

    Read docs/index.html for API documentation and check WhatsNew for important
    (API) changes.

    If you use SocketW in a free or commercial project, please let me know so that I
    can add a link to your project on the SocketW homepage!

    Patches, bugreports and comments are very much appreciated, please send them to
    the email address at the top of this document.

    This library is free software; you can redistribute it and/or modify it under
    the terms of the GNU Lesser General Public License as published by the Free
    Software Foundation; either version 2.1 of the License, or (at your option) any
    later version. This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
    Public License for more details.

    2. Requirements
    - GNU Make (if you want to use the makefiles).
    - An ANSI/ISO C++ compiler. SocketW should conform to ANSI/ISO C++.
    - OpenSSL (if you want SSL/TSL support)

    Most good C++ compilers should be able to compile SocketW provided that your
    system supports BSD style sockets and uses sane system headers. Additionally,
    the MS Windows platform is supported using the standard MS WinSock2 library.
    SocketW will use the GNU compiler g++ as default, but this can be changed in the
    file "Makefile.conf".

    3. Installing
    Just do make install to compile and install SocketW. SocketW will be installed
    in /usr/local as default but this can be controlled by changing the PREFIX
    line in "Makefile.conf". Make sure that the run-time linker can find the SocketW
    library after installation (this is usually done by adding the line
    /usr/local/lib to /etc/ld.so.conf and then running ldconfig).

    If OpenSSL is not installed in the standard location you might need to add
    -I/path/to/OpenSSL/include to CFLAGS and -L/path/to/OpenSSL/lib to SW_LIBS
    in "Makefile.conf", for example:
    CFLAGS =-Wall -O3 -ffast-math -I/opt/OpenSSL/include
    SW_LIBS =-L/opt/OpenSSL/lib -lssl -lcrypto

    You can also disable OpenSSL support completely by removing the line
    #define _HAVE_SSL in src/sw_config.h before compiling SocketW.

    Some platforms require extra libraries to use the BSD socket subsystem, for
    example Win32 requires that you add -lws2_32 to SW_LIBS (see section 5) and
    SUN systems requires -lsocket -lnsl.

    4. Library usage
    Just include the line #include "SocketW.h" in your code.

    The normal way to compile code that uses SocketW is with the flags
    -I/path/to/SocketW/inlude -I/path/to/OpenSSL/include if SocketW or OpenSSL
    are not installed to /usr (OpenSSL usually is).

    The normal way to link code that uses SocketW is with the flags
    -L/path/to/SocketW/lib -lSocketW. If you're using static linking then the
    flags -L/path/to/OpenSSL/lib -lssl -lcrypto also need to be added.

    Example:
    g++ -Wall -O3 -I/usr/local/inlude -c my_SocketW_app.cxx
    g++ -o my_SocketW_app my_SocketW_app.o -L/usr/local/lib -lSocketW

    5. Cross compiling SocketW to W32
    SocketW can be compiled by a win32 cross compiler. You need a cross compiled
    version of OpenSSL, precompiled binaries can be found at
    gnuwin32.sourceforge.net/packages/openssl.htm.

    A good precompiled cross compiler for x86 Linux can be found at
    www.libsdl.org/Xmingw32/index.html.

    Before compiling SocketW with cross-make dll change the line:
    SW_LIBS = -lssl -lcrypto #-lstdc++ -lws2_32
    in "Makefile.conf" into:
    SW_LIBS = -lssl -lcrypto -lstdc++ -lws2_32

    If you want to build a dll (cross-make dll or cross-make dll-strip) then you might
    want to do ln -s ../../bin/i386-mingw32msvc-dllwrap dllwrap in
    /usr/local/cross-tools/i386-mingw32msvc/bin.

    6. Using MS VisC/C++ or Borland CC
    Should work. You can use the precompiled binaries for OpenSSL if you don't want
    to compile them yourself. You can create compatible .lib (import) files for
    linking with:
    lib.exe /VERBOSE /MACHINE:I386 /DEF:foo.def /OUT:foo.lib /NAME:foo (for VC)
    implib.exe -f foo-bcc.lib foo (for Borland CC)
    (replace "foo" with the library name, e.g. SocketW or openssl).

    Use the libraries ws2_32 (WinSock2), ssl and crypto if you want to build
    SocketW yourself. You can also use the precompiled Win32 binaries of SocketW
    (available from the homepage) by creating import files as above for SocketW.

    7. Misc.
    You can read the html documentation and study the examples to learn more. Also,
    you should never trust the security of a library without checking yourself. That
    this library is free software makes this easier as you can check the source code
    directly. I also recommend using Ethereal to make sure your critical data is
    encrypted when needed. Just because you're paranoid, it doesn't mean you're
    wrong! :-)

    /Anders Lindström

Copyright © 2003 Anders Lindström
Last updated 031026