| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#ifndef SDLNETWRAPPER_H |
| 22 |
#define SDLNETWRAPPER_H |
| 23 |
|
| 24 |
#ifndef DOSBOX_DOSBOX_H |
| 25 |
#include "dosbox.h" |
| 26 |
#endif |
| 27 |
|
| 28 |
#if C_MODEM |
| 29 |
|
| 30 |
# ifndef DOSBOX_SUPPORT_H |
| 31 |
#include "support.h" |
| 32 |
#endif |
| 33 |
|
| 34 |
|
| 35 |
#define NETWRAPPER_TCP 1 |
| 36 |
#define NETWRAPPER_TCP_NATIVESOCKET 2 |
| 37 |
|
| 38 |
#if defined WIN32 |
| 39 |
#define NATIVESOCKETS |
| 40 |
#include <winsock2.h> |
| 41 |
#include <ws2tcpip.h> |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
#elif defined HAVE_STDLIB_H && defined HAVE_SYS_TYPES_H && defined HAVE_SYS_SOCKET_H && defined HAVE_NETINET_IN_H |
| 46 |
#define NATIVESOCKETS |
| 47 |
#define SOCKET int |
| 48 |
#include <stdio.h> |
| 49 |
#include <stdlib.h> |
| 50 |
#include <sys/types.h> |
| 51 |
#include <sys/socket.h> |
| 52 |
#include <netinet/in.h> |
| 53 |
|
| 54 |
#endif |
| 55 |
|
| 56 |
#ifdef NATIVESOCKETS |
| 57 |
#define CAPWORD (NETWRAPPER_TCP|NETWRAPPER_TCP_NATIVESOCKET) |
| 58 |
#else |
| 59 |
#define CAPWORD NETWRAPPER_TCP |
| 60 |
#endif |
| 61 |
|
| 62 |
#include "SDL_net.h" |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
Bit32u Netwrapper_GetCapabilities(); |
| 67 |
|
| 68 |
|
| 69 |
class TCPClientSocket { |
| 70 |
public: |
| 71 |
TCPClientSocket(TCPsocket source); |
| 72 |
TCPClientSocket(const char* destination, Bit16u port); |
| 73 |
#ifdef NATIVESOCKETS |
| 74 |
Bit8u* nativetcpstruct; |
| 75 |
TCPClientSocket(int platformsocket); |
| 76 |
#endif |
| 77 |
~TCPClientSocket(); |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
Bits GetcharNonBlock(); |
| 84 |
|
| 85 |
|
| 86 |
bool Putchar(Bit8u data); |
| 87 |
bool SendArray(Bit8u* data, Bitu bufsize); |
| 88 |
bool ReceiveArray(Bit8u* data, Bitu* size); |
| 89 |
bool isopen; |
| 90 |
|
| 91 |
bool GetRemoteAddressString(Bit8u* buffer); |
| 92 |
|
| 93 |
void FlushBuffer(); |
| 94 |
void SetSendBufferSize(Bitu bufsize); |
| 95 |
|
| 96 |
|
| 97 |
bool SendByteBuffered(Bit8u data); |
| 98 |
bool SendArrayBuffered(Bit8u* data, Bitu bufsize); |
| 99 |
|
| 100 |
private: |
| 101 |
TCPsocket mysock; |
| 102 |
SDLNet_SocketSet listensocketset; |
| 103 |
|
| 104 |
|
| 105 |
Bitu sendbuffersize; |
| 106 |
Bitu sendbufferindex; |
| 107 |
|
| 108 |
Bit8u* sendbuffer; |
| 109 |
}; |
| 110 |
|
| 111 |
class TCPServerSocket { |
| 112 |
public: |
| 113 |
bool isopen; |
| 114 |
TCPsocket mysock; |
| 115 |
TCPServerSocket(Bit16u port); |
| 116 |
~TCPServerSocket(); |
| 117 |
TCPClientSocket* Accept(); |
| 118 |
}; |
| 119 |
|
| 120 |
|
| 121 |
#endif |
| 122 |
|
| 123 |
#endif |