Bläddra i källkod

Fixed SIGPIPE bug - transmit and receive functions in networking were using NOFLAGS instead of NO_SIGNALS. As a result broken pipes would raise SIGPIPE on *nix systems -- the coded did not expect that. NO_SIGNALS is not defined for win* systems so an ifdef was added to create NO_SIGNALS like NOFLAGS where it is not defined on win* systems. Win* has no concept of signals so this is a non-event for win* systems.

git-svn-id: https://svn.microneil.com/svn/CodeDweller/trunk@15 d34b734f-a00e-4b39-a726-e4eeb87269ab
wx
madscientist 15 år sedan
förälder
incheckning
052a10b812
3 ändrade filer med 8 tillägg och 4 borttagningar
  1. 2
    2
      networking.cpp
  2. 4
    0
      networking.hpp
  3. 2
    2
      networking.inline.hpp

+ 2
- 2
networking.cpp Visa fil

@@ -410,7 +410,7 @@ int TCPClient::transmit(const char* bfr, int size) {
if(0 > size) // Watch out for bad sizes.
throw Networking::SocketWriteError("TCPClient::transmit() 0 > size!");

int ByteCount = send(Handle, bfr, size, NOFLAGS); // Try to send and capture the count.
int ByteCount = send(Handle, bfr, size, NO_SIGNALS); // Try to send and capture the count.
if(0 > ByteCount) ByteCount = 0; // Mask error results as 0 bytes sent.

if(size > ByteCount) { // If we didn't send it all check it out.
@@ -573,7 +573,7 @@ int TCPHost::transmit(const char* bfr, int size) {
if(0 > size) // Watch out for bad sizes.
throw Networking::SocketWriteError("TCPHost::transmit() 0 > size!");

int ByteCount = send(Handle, bfr, size, NOFLAGS); // Try to send and capture the count.
int ByteCount = send(Handle, bfr, size, NO_SIGNALS); // Try to send and capture the count.
if(0 > ByteCount) ByteCount = 0; // Mask error results as 0 bytes sent.

if(size > ByteCount) { // If we didn't send it all check it out.

+ 4
- 0
networking.hpp Visa fil

@@ -45,6 +45,10 @@ using namespace std;
#include <winsock2.h>
typedef int socklen_t; // Posix uses socklen_t so we mimic it.
typedef SOCKET hSocket; // Winx handles Socket is opaque.
#ifndef NO_SIGNALS
const int NO_SIGNALS = 0; // Make NO_SIGNALS for windows.
#endif

#else


+ 2
- 2
networking.inline.hpp Visa fil

@@ -299,7 +299,7 @@ inline bool TCPClient::ReadBufferIsEmpty() {
inline void TCPClient::fillReadBuffer() { // Fills the buffer from the socket.
LastError = 0; // Clear the LastError value.
ReadPointer = ReadBuffer; // Reset the ReadPointer.
DataLength = recv(Handle, ReadBuffer, sizeof(ReadBuffer), NOFLAGS); // Try to read some data.
DataLength = recv(Handle, ReadBuffer, sizeof(ReadBuffer), NO_SIGNALS); // Try to read some data.

if(0 >= DataLength) { // If there was an error then
LastError = Network.getLastError(); // Grab the last error code.
@@ -347,7 +347,7 @@ inline bool TCPHost::ReadBufferIsEmpty() {
inline void TCPHost::fillReadBuffer() { // Fills the buffer from the socket.
LastError = 0; // Clear the LastError value.
ReadPointer = ReadBuffer; // Reset the ReadPointer.
DataLength = recv(Handle, ReadBuffer, sizeof(ReadBuffer), NOFLAGS); // Try to read some data.
DataLength = recv(Handle, ReadBuffer, sizeof(ReadBuffer), NO_SIGNALS); // Try to read some data.

if(0 >= DataLength) { // If there was an error then
LastError = Network.getLastError(); // Grab the last error code.

Laddar…
Avbryt
Spara