summaryrefslogtreecommitdiffhomepage
path: root/NetEx
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-03-31 20:28:29 +0200
committerAki <please@ignore.pl>2022-03-31 20:28:29 +0200
commit8e0aa5f780e453b36a02471ab7a587376373044b (patch)
treeec8f033531adce25cfc01f7c0b7465c90a310660 /NetEx
parent8951abb7e436c6aabd2832ce4abea95ecae8192e (diff)
downloadstarshatter-8e0aa5f780e453b36a02471ab7a587376373044b.zip
starshatter-8e0aa5f780e453b36a02471ab7a587376373044b.tar.gz
starshatter-8e0aa5f780e453b36a02471ab7a587376373044b.tar.bz2
Removed windows.h include and types from NetSock
Diffstat (limited to 'NetEx')
-rw-r--r--NetEx/NetSock.cpp23
-rw-r--r--NetEx/NetSock.h19
2 files changed, 23 insertions, 19 deletions
diff --git a/NetEx/NetSock.cpp b/NetEx/NetSock.cpp
index 5d4f35d..9dc957d 100644
--- a/NetEx/NetSock.cpp
+++ b/NetEx/NetSock.cpp
@@ -3,20 +3,23 @@
Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
Copyright (c) 1997-2006, Destroyer Studios LLC.
- AUTHOR: John DiCamillo
+ AUTHOR: John DiCamillo
- OVERVIEW
- ========
- Network (IP) Socket Wrapper Implementation
+ OVERVIEW
+ ========
+ Network (IP) Socket Wrapper Implementation
*/
+#include "NetSock.h"
-// WINSOCK2.H MUST COME FIRST!!
#include <winsock2.h>
-#include "NetSock.h"
+#include <cstdint>
+
+#include "NetAddr.h"
#include "NetLayer.h"
+#include "Text.h"
// +-------------------------------------------------------------------+
@@ -38,7 +41,7 @@ NetSock::NetSock(bool str)
* PRIVATE: used only by the accept call to build a socket for
* a client connection to this server
*/
-NetSock::NetSock(SOCKET sock, bool str)
+NetSock::NetSock(int sock, bool str)
: s(sock), stream(str), closed(false), stat(0), current_timeout(9999)
{ }
@@ -120,7 +123,7 @@ NetSock::available()
{
if (closed || s == INVALID_SOCKET) return 0;
- DWORD nbytes = 0;
+ unsigned long nbytes = 0;
if (::ioctlsocket(s, FIONREAD, &nbytes) == 0)
return (int) nbytes;
@@ -328,10 +331,10 @@ NetSock::close()
// +--------------------------------------------------------------------+
-DWORD
+std::uint32_t
NetSock::max_packet_size() const
{
- DWORD size = 0;
+ std::uint32_t size = 0;
int len = sizeof(size);
::getsockopt(s, SOL_SOCKET, 0x2003, (char*) &size, &len);
diff --git a/NetEx/NetSock.h b/NetEx/NetSock.h
index 996972a..0df1cc6 100644
--- a/NetEx/NetSock.h
+++ b/NetEx/NetSock.h
@@ -3,25 +3,26 @@
Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
Copyright (c) 1997-2006, Destroyer Studios LLC.
- AUTHOR: John DiCamillo
+ AUTHOR: John DiCamillo
- OVERVIEW
- ========
- Network (IP) Socket
+ OVERVIEW
+ ========
+ Network (IP) Socket
*/
#ifndef NetSock_h
#define NetSock_h
-#include <windows.h>
+#include <cstdint>
+
#include "NetAddr.h"
#include "Text.h"
-// +-------------------------------------------------------------------+
#define NET_MAX_TIMEOUT 1e9
+
class NetSock
{
public:
@@ -53,15 +54,15 @@ public:
int set_timeout(int msecs);
int close();
- DWORD max_packet_size() const;
+ std::uint32_t max_packet_size() const;
bool is_stream() const { return stream; }
bool is_closed() const { return closed; }
int status() const { return stat; }
private:
- NetSock(SOCKET s, bool stream);
+ NetSock(int sock, bool stream);
- SOCKET s;
+ int s;
bool stream;
bool closed;
int stat;