한국리눅스유저그룹 위키페이지- LUG KOREA
|
|
| Kernel News | GNOME News | KDE News | linux.kernel | comp.lang.c++ | wxWidgets GUI | comp.lang.python | |
라이브러리 배포 사이트 : http://www.alhem.net/Sockets/
2.3 버전 : sockets-2.3.tar.gz
튜토리얼 : sockets-tutorial.tar.gz
[root@localhost src]# lftpget http://www.alhem.net/Sockets/Sockets-2.3.tar.gz
[root@localhost src]# tar xzf Sockets-2.3.tar.gz
[root@localhost src]# cd Sockets-2.3
[root@localhost Sockets-2.3]# ls
Ajp13Socket.cpp HttpdCookies.h ResolvSocket.h
Ajp13Socket.h HttpdForm.cpp SSLInitializer.cpp
AjpBaseSocket.cpp HttpdForm.h SSLInitializer.h
AjpBaseSocket.h HttpdSocket.cpp SctpSocket.cpp
Base64.cpp HttpdSocket.h SctpSocket.h
Base64.h IBase.h Semaphore.cpp
Changelog IEventHandler.h Semaphore.h
Debug.cpp IEventOwner.cpp SmtpdSocket.cpp
Debug.h IEventOwner.h SmtpdSocket.h
DevCpp IFile.h Socket.cpp
Event.cpp IHttpServer.h Socket.h
Event.h INSTALL SocketAddress.h
EventHandler.cpp ISocketHandler.h SocketHandler.cpp
EventHandler.h Ipv4Address.cpp SocketHandler.h
EventTime.cpp Ipv4Address.h Sockets-config.cpp
EventTime.h Ipv6Address.cpp StdLog.h
Exception.cpp Ipv6Address.h StdoutLog.cpp
Exception.h ListenSocket.h StdoutLog.h
File.cpp Lock.cpp StreamSocket.cpp
File.h Lock.h StreamSocket.h
HTTPSocket.cpp Makefile TcpSocket.cpp
HTTPSocket.h Makefile.Defines.linux-x86-32 TcpSocket.h
HttpBaseSocket.cpp Makefile.Defines.macosx Thread.cpp
HttpBaseSocket.h Makefile.Defines.solaris8 Thread.h
HttpClientSocket.cpp Makefile.Defines.solaris9-sparc-64 UdpSocket.cpp
HttpClientSocket.h Makefile.Defines.win32-cygwin UdpSocket.h
HttpDebugSocket.cpp Makefile.solaris9-sparc-64 Utility.cpp
HttpDebugSocket.h Makefile.version Utility.h
HttpGetSocket.cpp MemFile.cpp XmlDocument.cpp
HttpGetSocket.h MemFile.h XmlDocument.h
HttpPostSocket.cpp Mutex.cpp XmlException.cpp
HttpPostSocket.h Mutex.h XmlException.h
HttpPutSocket.cpp OSX.zip XmlNode.cpp
HttpPutSocket.h Parse.cpp XmlNode.h
HttpRequest.cpp Parse.h ajp13.h
HttpRequest.h Project gpl.txt
HttpResponse.cpp Project.net mkdot.sh
HttpResponse.h README.macosx socket_include.cpp
HttpTransaction.cpp ResolvServer.cpp socket_include.h
HttpTransaction.h ResolvServer.h sockets-config.h
HttpdCookies.cpp ResolvSocket.cpp tests
[root@localhost Sockets-2.3]# cat INSTALL
C++ Sockets Library :: installation instructions
Unix (and Cygwin/Mingw on windows)
==================================
1. Change the 'PLATFORM =' line in Makefile
Possible values are
linux-x86-32
win32-cygwin
solaris9-sparc-64
macosx
solaris8
2. If you want to use ssl encrypted socket communication, the library
has support for the third-party library openssl. If necessary, add
the following include directory to Makefile:
INCLUDE = -I<path to openssl>/include
The openssl include directory contains only one directory named
'openssl', in which all header files can be found.
OpenSSL support is enabled by default.
If you don't need encrypted communications, make sure to comment
out this line in the file 'sockets-config.h':
#define HAVE_OPENSSL
3. If you really need thread-safe dns lookups, and your operating has
support for *addrinfo and *nameinfo function calls, make sure this
line in 'sockets-config.h' is commented:
#define NO_GETADDRINFO
By default, dns lookups using getaddrinfo/getnameinfo is disabled.
4. If your operating system supports SCTP, there might be a slight
chance the sctp code in the library works. Uncomment this line in
'sockets-config.h' to try:
//#define USE_SCTP
5. If you need IPv6 support, uncomment this line in
'sockets-config.h':
//#define ENABLE_IPV6
6. Type 'make'
7. If all builds ok, you'll find the static library file 'libSockets.a'
in the build directory.
When compiling the application, any flags used when compiling the library
also needs to be present when including the library .h files. All flags
can be retrieved using the 'Sockets-config' executable. Add something like
this in your Makefile:
CFLAGS += `Sockets-config`
CPPFLAGS += `Sockets-config`
When linking an application using the library, make sure the object and
library files are in correct order on your link command line:
First: Application object files
2nd: -lSockets
3rd: openssl libraries
Finally: Everything else, ending with -lpthread
windows
=======
Project files for various IDE's can be found here:
Project/ Visual studio 6.0
Project.net/ Visual studio .NET
DevCpp/ Dev C++
Please see steps 2-5 above for some details on configuring the library.
When linking on cygwin/mingw, add the following libraries:
-lwsock32
-lws2_32
[root@localhost Sockets-2.3]#
기본설정은 openssl을 사용하도록 구성되어 있다. 여기서는 단지 prefix 옵션이 /usr/local로 되어 있다.
[root@localhost Sockets-2.3]# cat Makefile # platforms: # linux-x86-32 # win32-cygwin # solaris9-sparc-64 # macosx # solaris8 PLATFORM = linux-x86-32 # .h files installed to $(PREFIX)/include/Sockets # static lib .a files installed to $(PREFIX)/lib PREFIX = /usr/local [root@localhost Sockets-2.3]# make ... [root@localhost Sockets-2.3]# make install cp libSockets.a /usr/local/lib cp -a *.h /usr/local/include/Sockets install Sockets-config /usr/local/bin [root@localhost Sockets-2.3]#
Sockets 라이브러리를 사용하기 위해서는 #include 헤더파일 을 사용한다.
컴파일시 옵션으로 -I/usr/local/include/Sockets 옵션을 붙여주고
라이브러리 경로와 .a 파일을 링크하도록 -L/usr/local/lib -lSockets -lpthread -lssl -lcrypto 을 입력해준다.
즉, 아래의 형식으로 컴파일 한다.
# g++ [컴파일할 소스파일들] -o [생성될 실행파일] -I/usr/local/include/Sockets -L/usr/local/lib -lSockets -lpthread -lssl -lcrypto
# lftpget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.$dist.rf.$arch.rpm # rpm -Uhv rpmforge-release-0.3.6-1.$dist.rf.$arch.rpm
Distributions
RHEL / CentOS
TIP For CentOS Yum users there is a very good document on how to enable RPMforge safely using the Yum priorities plugin
RHEL5 / CentOS-5
i386: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
x86_64: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
RHEL4 / CentOS-4
i386: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el4.rf.i386.rpm
x86_64: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el4.rf.x86_64.rpm
RHEL3 / CentOS-3
i386: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el3.rf.i386.rpm
x86_64: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el3.rf.x86_64.rpm
RHEL2.1 / CentOS-2
i386: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el2.rf.i386.rpm
Red Hat Linux
Red Hat 9
i386: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.rh9.rf.i386.rpm
Red Hat 7.3
i386: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.rh7.rf.i386.rpm
위에서 자신의 서버에 맞는 rpm 파일을 설치하고 yum 으로 아래 두개의 라이브러리를 설치한다.
# yum install csockets csockets-devel
.h 헤더파일 file : /usr/include/Sockets
.a 라이브러리 file : /usr/lib/libSockets.a