Websocket send

This commit is contained in:
2020-12-01 21:22:00 +01:00
parent a995ed5090
commit ddd3e6e7f1
3 changed files with 17 additions and 3 deletions

View File

@ -227,7 +227,7 @@ int websocket_handler(Socket *socket, stds *pipes) {
socket->receive(pipes->stdin);
} else {
ungetc(c, pipes->stdout);
socket->send(pipes->stdout, -1);
socket->send(pipes->stdout);
}
}
}

View File

@ -236,6 +236,18 @@ long Socket::send(const char *str) {
return send(str, strlen(str));
}
long Socket::send(FILE *file) {
char buffer[CPPNET_CHUNK];
long all_len = 0;
long len = 0;
do {
len = fread(buffer, 1, CPPNET_CHUNK, file);
send(buffer, len);
all_len += len;
} while (len > 0 && len == CPPNET_CHUNK);
return all_len;
}
Socket::~Socket() {
}

View File

@ -34,6 +34,8 @@ private:
void setSocketOption(int, bool);
long send(void *buffer, int size);
long receive(void *buffer, int size);
long peek(void *buffer, int size);
@ -63,8 +65,6 @@ public:
void sslHandshake(string privkey, string fullchain);
long send(void *buffer, int size);
long send(string *str);
long send(string str);
@ -73,6 +73,8 @@ public:
long send(const char *str, long length);
long send(FILE *file);
string receive();
string receive(long length);