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

View File

@ -64,13 +64,17 @@ EQStreamFactory::EQStreamFactory(EQStreamType type, int port, uint32 timeout)
void EQStreamFactory::Close()
{
Stop();
CloseWithoutStop();
}
#ifdef _WINDOWS
closesocket(sock);
#else
close(sock);
#endif
sock=-1;
void EQStreamFactory::CloseWithoutStop()
{
#ifdef _WINDOWS
closesocket(sock);
#else
close(sock);
#endif
sock=-1;
}
bool EQStreamFactory::Open()
@ -93,8 +97,7 @@ struct sockaddr_in address;
}
if (bind(sock, (struct sockaddr *) &address, sizeof(address)) < 0) {
close(sock);
sock=-1;
CloseWithoutStop();
return false;
}
#ifdef _WINDOWS

View File

@ -35,7 +35,7 @@ class EQStreamFactory : private Timeoutable {
Timer *DecayTimer;
uint32 stream_timeout;
void CloseWithoutStop();
public:
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);
@ -47,6 +47,7 @@ class EQStreamFactory : private Timeoutable {
bool Open(unsigned long port) { Port=port; return Open(); }
bool IsOpen() { return sock!=-1; }
void Close();
void ReaderLoop();
void WriterLoop();
void Stop() { StopReader(); StopWriter(); }