Click here to Skip to main content
15,892,746 members
Articles / Desktop Programming / MFC

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.5K   8.2K   36  
Offers services by servers, use of services by clients, via IP sockets.
#ifndef	__SOC_src
#define	__SOC_src 1
// ====================================================================	//
//			    S O C _ s r c . h				//
// --------------------------------------------------------------------	//
// The Socket library needs this header file.				//
// ====================================================================	//

// ============================================================	//
// Include files						//
// ============================================================	//
#include "SOCcalls.h"

// ============================================================	//
// Definitions							//
// ============================================================	//
#define	SOCver	"3.4.1.1"
#define	SOCdat	"05/04/05"

#define	dbgjpmval   0		// 0none,1thread,2user,3all,4basic

// ============================================================	//
// Typedefs							//
// ============================================================	//
typedef struct {long siz; char err[32];}err_typ;

// ============================================================	//
// MH_typ Typedef						//
// ============================================================	//
#ifndef	MHv			//Mn    Mx  Actual
#define	MHv  0			// 0 to  1     0
#endif
#ifndef	MHt
#define	MHt  7			// 1 to  7     7
#endif
#ifndef	MHi
#define	MHi  0			// 0 to 25     0
#endif
#ifndef	MHs
#define	MHs 15			// 0 to 20    15
#endif
#ifndef	MHd
#define	MHd  4			// 2 to  7     4
#endif				//--	--    --
				// 3 to 60    26

typedef struct {		// Standard header message
	char MagicNumber[  3+1];// 3  chars, zero terminated
	char	Version	[MHv+1];// 1  char,  zero terminated
	char	Type	[MHt+1];// 7  chars, zero terminated
	char  Identifier[MHi+1];//25  chars, zero terminated
	char	Sender	[MHs+1];//20  chars, zero terminated
	char	DataSize[MHd+1];// 7  chars, zero terminated, (<sp> & 0-9 only)
}MH_typ;		//  --	  --
			//  69	//63	Maximum
			//  12	// 6	Minimum
			//  35	//29	Actual

// ============================================================	//
// soc_typ Typedef						//
// ============================================================	//
typedef struct {		// Each heard socket has one of these
	byte	nr;		// Socket number
	byte	thnr;		// For this thread number
	byte	so_in_op;	// Socket in operation
	byte	input;		// Input available on 'soc' & not yet read
	long	excess;		// Unread portion of last message
	SOCKET	soc;		// Socket
	HANDLE	keyh;		// Event flag assosiated with above
	short	ctr[3];		// message counters
	char	Type[MHt+1];	// 7  chars, zero terminated
	byte	mortal;		// this socket deleteable
}soc_typ;

// ============================================================	//
// thr_typ Typedef						//
// ============================================================	//
typedef struct {		// Each spun off thread has one of these
	byte	nr;		// Thread number
	byte	th_in_op;	// Thread in operation
	byte	ls_in_op;	// Listening socket in operation
	byte	ss_in_op;	// Sockets in operation
	byte	exit_rqst;	// Exit request
	char	error;		// Error
	char	errorthread;	// Error while thread cycling
	char	errorclosure;	// Error while thread closing
	long	error2;		// Error from NT associated with above
	long	errorthread2;	// Error from NT associated with above
	long	errorclosure2;	// Error from NT associated with above
	short	port;		// "well kent port number" for this service
	long	ipad;		// TCPIP address for this service
	HANDLE	fh;		// Flag(Set by thread on arrival of a ms, reset by user recv
				//	when no sockets on thread have an ms outstanding)
	HANDLE	cr;		// Flag(Set by client user recv, auto-reset)
	SOCKET	soc;		// Listening socket on server
	char servicena[MX_SV_LEN+1];// Service name (up to 15 chars)
}thr_typ;


#endif//__SOC_src


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

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