Use os agnostic Close instead of windows deprecated close.

use the defined Close function instead of the internal (and linux
specific) Close command
This commit is contained in:
Arthur Ice
2014-04-10 15:34:23 -07:00
committed by Arthur Dene Ice
parent b2c9ba5bff
commit 5da3301570
2 changed files with 13 additions and 9 deletions
+8 -5
View File
@@ -64,12 +64,16 @@ EQStreamFactory::EQStreamFactory(EQStreamType type, int port, uint32 timeout)
void EQStreamFactory::Close() void EQStreamFactory::Close()
{ {
Stop(); Stop();
CloseWithoutStop();
}
#ifdef _WINDOWS void EQStreamFactory::CloseWithoutStop()
{
#ifdef _WINDOWS
closesocket(sock); closesocket(sock);
#else #else
close(sock); close(sock);
#endif #endif
sock=-1; sock=-1;
} }
@@ -93,8 +97,7 @@ struct sockaddr_in address;
} }
if (bind(sock, (struct sockaddr *) &address, sizeof(address)) < 0) { if (bind(sock, (struct sockaddr *) &address, sizeof(address)) < 0) {
close(sock); CloseWithoutStop();
sock=-1;
return false; return false;
} }
#ifdef _WINDOWS #ifdef _WINDOWS
+2 -1
View File
@@ -35,7 +35,7 @@ class EQStreamFactory : private Timeoutable {
Timer *DecayTimer; Timer *DecayTimer;
uint32 stream_timeout; uint32 stream_timeout;
void CloseWithoutStop();
public: public:
EQStreamFactory(EQStreamType type, uint32 timeout = 135000) : Timeoutable(5000), stream_timeout(timeout) { ReaderRunning=false; WriterRunning=false; StreamType=type; sock=-1; } EQStreamFactory(EQStreamType type, uint32 timeout = 135000) : Timeoutable(5000), stream_timeout(timeout) { ReaderRunning=false; WriterRunning=false; StreamType=type; sock=-1; }
EQStreamFactory(EQStreamType type, int port, uint32 timeout = 135000); EQStreamFactory(EQStreamType type, int port, uint32 timeout = 135000);
@@ -47,6 +47,7 @@ class EQStreamFactory : private Timeoutable {
bool Open(unsigned long port) { Port=port; return Open(); } bool Open(unsigned long port) { Port=port; return Open(); }
bool IsOpen() { return sock!=-1; } bool IsOpen() { return sock!=-1; }
void Close(); void Close();
void ReaderLoop(); void ReaderLoop();
void WriterLoop(); void WriterLoop();
void Stop() { StopReader(); StopWriter(); } void Stop() { StopReader(); StopWriter(); }