You are here:

C++/C++ socket programming


QUESTION: Is there any classes specific to C++ for handling sockets??...are sockets used for inter process communication in a single system??...what are the other C++ IPC specific to C++??

ANSWER: Is there any classes specific to C++ for handling sockets??

No. Not in the standard C++ library.

...are sockets used for inter process communication in a single system??

Yes. See for example the PF_UNIX/PF_LOCAL address families.

...what are the other C++ IPC specific to C++??

None. C++ is a general purpose programming language. It has no such concepts specific to C++ and only C++.

Having answered your questions as asked I shall read a bit between the lines and give you some additional information that is probably more the sort of thing you were after to start with.

Facilities such as IPC and sockets are usually provided as part of the operating system. Of course an operating system is implemented using one or more programming languages - C and/or C++ plus a little assembler might be common choices. Hence C++ could be used to implement sockets and other IPC features - for example on an embedded device with little or no operating system to speak of and an unhosted (no standard library) implementation of C++ any required features - including network protocol stacks that the PF_INET and PF_INET6 socket address/protocol families rely on - sockets, threads and synchronisation, pipes, shared memory, file systems etc. will all need to be developed or provided through existing libraries. Maybe on an operating system that has no socket APIs but has the facilities required to create an implementation then such a library could be written independently of the operating system.

So how do we access such facilities from C++? Well we can use the raw operating system provided APIs - which differ among operating systems and even within implementations of similar operating systems (UNIX like systems can offer System V and/or BSD/POSIX APIs (e.g. shared memory can be provided by either - or both - the System V shm - shmget, shmbuf etc, or the BSD mmap, munmap etc. APIs). Sockets are better in that when we say sockets we usually mean Berkeley (BSD) sockets - and the main variation to this would be from Microsoft for their various Windows platforms in the form of the Winsock APIs.

Other than the problems of different APIs and API variations there is also the problem that these raw operating system APIs are (usually) C APIs and generally allow you to easily use them in inconsistent and incorrect ways. C++ has various features that could be put to good use to improve on this situation in the form of C++ libraries that wrap up and abstract us from these raw operating APIs.

An obvious initial example would be to provide socket based streams based on the C++ IOStreams library - and indeed this has been done many times by various people (but not by me as it happens <g>...).

There are various C++ libraries around that provide support for network (and IPC) programming. Two that come to mind are the ACE library - see and more recently the Boost libraries -, specifically the Asio ( and Interprocess ( libraries.

Douglas C. Schmidt of the ACE library has written various books (often with others). Two that come immediately to mind in relation to this question are "C++ Network Programming" volumes 1 and 2, written in conjunction with Stephen D. Huston (,

You might find the Wikipedia article on Berkeley sockets of use:

Hope this has been of use.

[an error occurred while processing this directive]---------- FOLLOW-UP ----------

QUESTION: there any dis/similarities with C++ & Symbian C++ IPC and threads??

Umm, sorry what? I do not understand what you mean.

A (current) ISO standard hosted C++ implementation has _no_ support for threads _or_ IPC (other than maybe using files) (note: the next version of the ISO C++ standard looks likely to at least add support for basic threads and synchronisation - see for a reasonably up to date summary of the state of proposed features/changes for the next ISO C++ standard).

Symbian is an operating system implemented using (originally a subset of) C++ (exceptions were not that common when they started so Symbian OS had its own variation on a this theme - I believe they have managed to integrate the Symbian OS 'exception' model with C++ exceptions better).I would say that the Symbian OS could be considered a large embedded operating system rather than a cut down desktop operating system - many of the oddities of writing C++ for the Symbian OS stem from this small systems perspective.

Hence the similarities are that the core C++ language for the Symbian OS has no thread or IPC support either (and  no standard C++ library support - although I think there are third party implementations available). The dissimilarities are that when writing programs for the Symbian OS (in C++) you can use Symbian OS services such as threads and IPC (of course this could be said to be similar to writing C++ for any operating system and using the services it provides).

For recent versions of the Symbian OS you can also use POSIX (see style services using P.I.P.S. (P.I.P.S. is POSIX on Symbian OS - see - which could be a similarity with C++ written using POSIX services.

For more specifics on using C++ on the Symbian platform you might look for information on specific variants such as the Nokia S60 Platform:

You might notice on this page a link to a document detailing specific differences between ISO/ANSI C++ and 'Symbian C++' (and conventions used when writing C++ for software targeting the Symbian platform):

(note that is a very long URL so may have wrapped).

If this does not answer your question - as it may well not do as I am not at all sure what it is you are really asking about - then please ask further questions with more specific details on what it is you wish to know about. If you continue to be so vague then I shall not be able to add much more...  


All Answers

Answers by Expert:

Ask Experts


Ralph McArdell


I am a software developer with more than 15 years C++ experience and over 25 years experience developing a wide variety of applications for Windows NT/2000/XP, UNIX, Linux and other platforms. I can help with basic to advanced C++, C (although I do not write just-C much if at all these days so maybe ask in the C section about purely C matters), software development and many platform specific and system development problems.


My career started in the mid 1980s working as a batch process operator for the now defunct Inner London Education Authority, working on Prime mini computers. I then moved into the role of Programmer / Analyst, also on the Primes, then into technical support and finally into the micro computing section, using a variety of 16 and 8 bit machines. Following the demise of the ILEA I worked for a small company, now gone, called Hodos. I worked on a part task train simulator using C and the Intel DVI (Digital Video Interactive) - the hardware based predecessor to Indeo. Other projects included a CGI based train simulator (different goals to the first), and various other projects in C and Visual Basic (er, version 1 that is). When Hodos went into receivership I went freelance and finally managed to start working in C++. I initially had contracts working on train simulators (surprise) and multimedia - I worked on many of the Dorling Kindersley CD-ROM titles and wrote the screensaver games for the Wallace and Gromit Cracking Animator CD. My more recent contracts have been more traditionally IT based, working predominately in C++ on MS Windows NT, 2000. XP, Linux and UN*X. These projects have had wide ranging additional skill sets including system analysis and design, databases and SQL in various guises, C#, client server and remoting, cross porting applications between platforms and various client development processes. I have an interest in the development of the C++ core language and libraries and try to keep up with at least some of the papers on the ISO C++ Standard Committee site at


©2017 All rights reserved.

[an error occurred while processing this directive]