Introduction
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.
Background
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.
History
- 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.