Click here to Skip to main content
15,885,757 members
Articles / Desktop Programming / MFC

Timers & Sockets

Rate me:
Please Sign up or sign in to vote.
4.10/5 (5 votes)
7 Apr 20052 min read 43.7K   3.7K   22  
Control of timers, timings, offered services, and used services.
#ifndef	__SOCcalls
#define	__SOCcalls 1
// ====================================================================	//
//			    S O C c a l l s . h				//
// --------------------------------------------------------------------	//
// All users are to include this header file				//
// ====================================================================	//

// ============================================================	//
// Conditional definitions					//
// ============================================================	//
#ifndef SOC_EMERGENCY_READval
#define	SOC_EMERGENCY_READval	3000	// milliseconds before emergency read
#endif

#ifndef MX_NR_SOC
#define	MX_NR_SOC		 400	// Maximum (heard)Sockets
#endif

#ifndef MX_NR_THR
#define	MX_NR_THR		  20	// Maximum Threads
#endif

#ifndef MX_SV_LEN
#define	MX_SV_LEN		  15	// Maximum service name length
#endif

#ifndef MHs
#define	MHs			  15	// Maximum Sender name length
#endif

#ifndef MHt
#define	MHt			   7	// Maximum Type string length
#endif

// ============================================================	//
// Definitions							//
// ============================================================	//
#define	CLIENT			   0	// Must be zero
#define	SERVER		   	   1	// Must be non-zero

// ============================================================	//
// Successes always have bit 0 set				//
//								//
// Errors are returned either directly to callers or are plugged//
// into the "th" array element associated with the thread at	//
// error,  errorthread  or errorclosure & 2ndry errors at	//
// error2, errorthread2 or errclosure2.				//
// ============================================================	//
#define	SOC_SUCCESS		  1	//	  successes
#define	SOC_SUCCESS_NO_THREAD	  3	//
#define	SOC_SUCCESS_NO_SOCKETS	  5	// Server successes
#define	SOC_SUCCESS_NO_LSOCKET	  7	//
#define	SOC_SUCCESS_NO_SOCKET	  9	// Client successes

#define	SOC_FAILURE		 -2	//	  failures
#define	SOC_NO_MSG_AVAILABLE	 -4	//
#define	SOC_NO_THREAD_AVAILABLE	 -6	//
#define	SOC_NO_SOCKET_AVAILABLE	 -8	//
#define	SOC_NO_SUCH_SOCKET	-10	//
#define	SOC_NO_SUCH_SERVICE	-12	//
#define	SOC_SOCKET_ERROR	-14	//		    from recv/send
#define	SOC_INVALID_SOCKET	-16	//		    from accept/connect/socket
#define	SOC_NO_SUCH_SERVER	-18	// Server failures
#define	SOC_BIND_FAILED		-20	//		    from bind
#define	SOC_LISTEN_FAILED	-22	//		    from listen
#define	SOC_WAIT_FAILED		-24	//		    from WaitForMultipleObjects
#define	SOC_SERVER_REMOTE	-26	//		    SERVER not on Local Node
#define	SOC_SERVER_THREAD_CRASH	-28	//		    thread crashed
#define	SOC_NO_SUCH_CLIENT	-30	// Client failures
#define	SOC_CONNECT_FAILED	-32	//		    from connect
#define	SOC_CLIENT_THREAD_CRASH	-34	//		    thread crashed

#ifdef SOCDLL_API			    // This is "not using the DLL"
#else
 #ifdef SOCDLL_EXPORTS
  #define SOCDLL_API __declspec(dllexport)  // This is "building the DLL"
 #else
  #define SOCDLL_API __declspec(dllimport)  // This is "using the DLL"
 #endif
#endif
// ====================================================================	//
// Function prototypes							//
// ====================================================================	//
extern "C" SOCDLL_API char* _stdcall SOC_getVersion	(void);
extern "C" SOCDLL_API char* _stdcall SOC_getDate	(void);
extern "C" SOCDLL_API void	     SOC_set_debug	(long);

#define	FD_SETSIZE (MX_NR_SOC+1)	// Override the default size in windows.h
#include "windows.h"
extern "C" SOCDLL_API long  _stdcall SOC_launch_server	(HANDLE*,char*);
extern "C" SOCDLL_API long  _stdcall SOC_rcv_msg	(char*,long*,char*,long*,char*,bool);
extern "C" SOCDLL_API long  _stdcall SOC_rcv_msgfrom	(char*,long*,char*,long*,char*,bool);
extern "C" SOCDLL_API long  _stdcall SOC_snd_msgto	(char*,long*,char*,long*,char*);
extern "C" SOCDLL_API long  _stdcall SOC_get_s_svce_sonr(char*);
extern "C" SOCDLL_API long  _stdcall SOC_remove_sonr	(long);
extern "C" SOCDLL_API long  _stdcall SOC_close_server	(char*);

extern "C" SOCDLL_API long  _stdcall SOC_launch_client	(HANDLE*,char*);
extern "C" SOCDLL_API long  _stdcall SOC_close_client	(char*);

extern "C" SOCDLL_API void  _stdcall SOC_aIPtoL		(char*,short);
extern "C" SOCDLL_API void  _stdcall SOC_NAtoIP		(char*,char*);
extern "C" SOCDLL_API void	     SOC_sleepy_socket_x(void*);
extern "C" SOCDLL_API void  _stdcall SOC_reset		(void);

extern "C" SOCDLL_API long  _stdcall SOC_get_LputSender (char*);
extern "C" SOCDLL_API long  _stdcall SOC_get_Sender	(char*);
extern "C" SOCDLL_API long  _stdcall SOC_put_Sender	(char*);

extern "C" SOCDLL_API char* _stdcall SOC_errtxt		(long);


#endif//__SOCcalls


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