Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelboldt committed Sep 3, 2016
1 parent 158a79a commit 1b0a9c8
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 5 deletions.
28 changes: 28 additions & 0 deletions sockets/base64.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
/*
base64.cpp and base64.h
http://www.adp-gmbh.ch/cpp/common/base64.html
Copyright (C) 2004-2008 René Nyffenegger
This source code is provided 'as-is', without any express or implied
warranty. In no event will the author be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this source code must not be misrepresented; you must not
claim that you wrote the original source code. If you use this source code
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original source code.
3. This notice may not be removed or altered from any source distribution.
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
*/

#include "base64.h"

static const std::string base64_chars =
Expand Down
29 changes: 29 additions & 0 deletions sockets/base64.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
/*
base64.cpp and base64.h
http://www.adp-gmbh.ch/cpp/common/base64.html
Copyright (C) 2004-2008 René Nyffenegger
This source code is provided 'as-is', without any express or implied
warranty. In no event will the author be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this source code must not be misrepresented; you must not
claim that you wrote the original source code. If you use this source code
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original source code.
3. This notice may not be removed or altered from any source distribution.
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
*/


#pragma once
#ifndef _BASE64_H_
#define _BASE64_H_
Expand Down
2 changes: 0 additions & 2 deletions sockets/sockets.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

#define _CRT_SECURE_NO_WARNINGS
#include "websockets.h"



int main(int argc, char *argv[])
{

Expand Down
5 changes: 3 additions & 2 deletions sockets/websockets.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#define _CRT_SECURE_NO_WARNINGS

#include "websockets.h"

Websockets_connection::Websockets_connection(const char* ip, u_short port, const char* host, const unsigned char* key)
{
WSADATA wsa;
struct sockaddr_in server;
char server_reply[20000];
// char msg[2000] = "GET ws://192.168.137.6/ HTTP/1.1\r\nHost: MBO\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Version: 13\r\nSec-WebSocket-Key: ";
char* message = new char[2000];
char* str2 = new char[200];
int recv_size;
Expand Down Expand Up @@ -58,7 +59,7 @@ Websockets_connection::Websockets_connection(const char* ip, u_short port, const

// send data

int sr = send(s, message, strlen(message), 0);
int sr = send(s, message, (int)strlen(message), 0);
if (sr == SOCKET_ERROR)
{
puts("Send failed");
Expand Down
8 changes: 7 additions & 1 deletion sockets/websockets.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@

#ifndef WEBSOCKETS_H
#define WEBSOCKETS_H

#include<stdio.h>
#define _WINSOCK_DEPRECATED_NO_WARNINGS

Expand All @@ -19,4 +23,6 @@ class Websockets_connection {
private:
bool connected = FALSE;
SOCKET s;
};
};

#endif /* websockets.h */

0 comments on commit 1b0a9c8

Please sign in to comment.