Click here to Skip to main content
15,881,173 members
Articles / Desktop Programming / MFC
Article

Server & Client IP Sockets

Rate me:
Please Sign up or sign in to vote.
3.30/5 (7 votes)
6 Apr 20052 min read 63.4K   8.2K   36   5
Offers services by servers, use of services by clients, via IP sockets.

Sample Image

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.

License

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


Written By
Web Developer
United Kingdom United Kingdom
BSc (St.Andrews(1963-67))
MSCE
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)

Comments and Discussions

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

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

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