PIPeer important fix!

git-svn-id: svn://db.shs.com.ru/pip@113 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
2015-04-20 10:18:45 +00:00
parent 8c6370fda5
commit 4ae10c905c
4 changed files with 9 additions and 7 deletions

View File

@@ -272,7 +272,7 @@ bool PIEthernet::closeDevice() {
void PIEthernet::closeSocket(int & sd) {
if (sd != -1)
ethClosesocket(sd);
ethClosesocket(sd, type() != PIEthernet::UDP);
sd = -1;
}
@@ -1035,13 +1035,14 @@ int PIEthernet::ethSendto(int sock, const void * buf, int size, int flags, socka
}
void PIEthernet::ethClosesocket(int sock) {
void PIEthernet::ethClosesocket(int sock, bool shutdown) {
if (sock < 0) return;
if (shutdown) ::shutdown(sock,
#ifdef WINDOWS
shutdown(sock, SD_BOTH);
SD_BOTH);
closesocket(sock);
#else
shutdown(sock, SHUT_RDWR);
SHUT_RDWR);
::close(sock);
#endif
}