What the...?

Something bad happened

We're not sure what, but we have a few guesses.

Problem: Object reference not set to an instance of an object.
Ticket: 7864836
Server: Web04
Server & Client IP Sockets - CodeProject Click here to Skip to main content
11,715,022 members (68,364 online)
Click here to Skip to main content

Server & Client IP Sockets

, 6 Apr 2005 54.9K 7.1K 36
Rate this:
Please Sign up or sign in to vote.
Offers services by servers, use of services by clients, via IP sockets.

Sample Image


This DLL provides nineteen routines to satisfy application program requirements for client/service socket activities in a C/C++ and VB environment. The praxis is that 400 sockets on 20 service threads are enough for an application.


Seven server routines are provided. Upon server thread launch, the thread creates a listening-socket that will generate a socket for every client it hears. When a message is heard on a socket, the event-flag associated with the socket will be set. When a message is accepted by the server application, the flag is reset.

Four client routines are provided. Upon client thread launch, the thread creates a socket that connects to the required service. When a message is heard at the socket, the event-flag associated with the socket will be set. When a message is accepted by the client application, the flag is reset.

Eight auxiliary routines are provided (for the use of both server and client); two routines to obviate the need to use the %systemroot%\system32\drivers\etc\services. file; a housekeeping routine; a reset routine; three routines to manipulate the message header information; a routine to convert an error number to text string.

Using the code

VC 6.0 projects:

  • Place the SOCDLL.dll in a directory on your path variable.
  • Add the library SOCDLL.lib to the project resources.
  • Add the module SOCcalls.h to the project.
  • Use the routines therein.

VB 6.0 projects:

  • Register the SOCDLL.dll with regsvr32.
  • Add the module SOCDLL.bas to the project.
  • Use the public routines therein.

Points of Interest

For C/C++ only users, a static library can be built using the workspace and project files provided.

Demo Programs

The C/C++ client may be run with the C/C++ or VB server. The VB client may be run with the C/C++ or VB server. Many instances of either or both C/C++ or VB client may be run concurrently with either the C/C++ or the VB server.

The server spins off three server threads for CuService, AgService and AuService. The server closes down its socket sub-system after 21 replies to clients.

The client randomly spins off one of the three possible client threads for the above services. The client sends three messages with a randomly chosen Type of Abel, Baker, Charlie, Delta, Echo or Foxtrot. The client closes down its socket sub-system.


  • 3.4 - SOC_Src.cpp Comment/Logging maintenance.
  • 3.2 - Server-side 'select' timeout is reduced from 50 to 1 millisecond. This allows faster transfer, though one's machine will get busier.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United Kingdom United Kingdom
BSc (St.Andrews(1963-67))
Systems Programmer 39+yrs
Married to first wife 35yrs & counting, four grown-up children
Religious opinions similar to MelG's
It is not the gnosis, but the praxis must be the fruit. (Aristotle)

You may also be interested in...

Comments and Discussions

General[Message Deleted] Pin
it.ragester2-Apr-09 21:56
memberit.ragester2-Apr-09 21:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150901.1 | Last Updated 7 Apr 2005
Article Copyright 2004 by Lymington
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid