SimpleSocket library

2013年6月11日 由 Creater 留言 »

Introduction

SimpleSocket is a C++ library making socket based client/server programming easier. The library consists of the classes Socket and ServerSocket. These classes can be used in a similar way as the Java classes of the same name. It makes use of C++ stream to send data to and fro. SimpleSocket has been tested in the GNU cygwin environment on both Windows98 and Windows NT4 and on a Silicon Graphics Origin200 (IRIX 6.5). The library is expected to work on Linux or other Unix variants, with few changes. SimpleSocket makes use of the SimpleException and SimpleMessage libraries. These libraries can also be used for other purposes.
Installation

Download the SimpleSocket library and save it to a new directory. In this directory type the following:
%gunzip SimpleSock.tar.gz
%tar xf SimpleSock.tar
The following files are extracted from the archive:
SimpleSock.cpp SimpleSock.h SimpleException.h
ssock_client.cpp ssock_server.cpp SimpleMessage.h
Makefile Makefile.cygwin Makefile.sgi
If you use the cygwin environment, type:
%cp Makefile.cygwin Makefile
If you use the SGI MIPSPRO C++ compiler on IRIX, type:
%cp Makefile.sgi Makefile
On other platforms you may need to make changes to one of these makefiles.

Make the SimpleSocket library, the test server (ssock_server) and the test client (ssock_client):
%make
Test the library

To test the library, run the server (in the background) and the client:
%ssock_server&

%ssock_client
Create your own client/server apps

After taking a look at the make files and the sources, it should be clear how to make your own socket based client/server applications. Make sure that you use exceptions to catch errors. If your server has to handle more than one client, you probably need to use threads. Good luck!

广告位

发表评论

你必须 登陆 方可发表评论.