1 // This is a simple class to handle socket connections 2 // (Paul Brannan 6/15/98) 3 4 #pragma once 5 6 //#include <windows.h> 7 8 enum NetworkType {TN_NETSOCKET, TN_NETPIPE}; 9 10 typedef int(*Naws_func_t)(char *, int, int); 11 12 class TNetwork { 13 private: 14 SOCKET socket; 15 BOOL local_echo; // Paul Brannan 8/25/98 16 BOOL line_mode; // Paul Brannan 12/31/98 17 NetworkType net_type; // Paul Brannan 3/18/99 18 HANDLE pipeIn, pipeOut; // Paul Brannan 3/18/99 19 Naws_func_t naws_func; 20 char *local_address; 21 22 public: socket(s)23 TNetwork(SOCKET s = 0): socket(s), local_echo(1), line_mode(1), 24 net_type(TN_NETSOCKET), naws_func((Naws_func_t)NULL), 25 local_address((char *)NULL) {} ~TNetwork()26 ~TNetwork() {if(local_address) delete[] local_address;} 27 28 void SetSocket(SOCKET s); GetSocket()29 SOCKET GetSocket() {return socket;} 30 void SetPipe(HANDLE pIn, HANDLE pOut); SetNawsFunc(Naws_func_t func)31 void SetNawsFunc(Naws_func_t func) {naws_func = func;} 32 void SetLocalAddress(char *buf); GetLocalAddress()33 const char* GetLocalAddress() {return local_address;} 34 get_net_type()35 NetworkType get_net_type() {return net_type;} 36 37 int WriteString(const char *str, const int length); 38 int ReadString (char *str, const int length); 39 get_local_echo()40 BOOL get_local_echo() {return local_echo;} set_local_echo(BOOL b)41 void set_local_echo(BOOL b) {local_echo = b;} 42 get_line_mode()43 BOOL get_line_mode() {return line_mode;} set_line_mode(BOOL b)44 void set_line_mode(BOOL b) {line_mode = b;} 45 46 void do_naws(int width, int height); 47 }; 48