blob: 370aeb74f7f7f9d4e79a2838a83f66d53c3794b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// Copied from http://linuxgazette.net/issue74/tougher.html
// (only slightly modified)
// Definition of the Socket class
#ifndef Socket_class
#define Socket_class
#include "stdafx.h"
#include <sys/types.h>
//#include <netinet/in.h>
//#include <netdb.h>
//#include <unistd.h>
#include <string>
//#include <arpa/inet.h>
#include <winsock2.h>
#include "socketexception.h"
const int MAXHOSTNAME = 200;
const int MAXCONNECTIONS = 5;
const int MAXRECV = 500;
class Socket
{
public:
//proxy hinzugefügt dufte
Socket( std::string host, int port,int useproxy = 0,std::string proxyhost = " ", int proxyport = 0 );
virtual ~Socket();
// Server initialization
bool create();
bool bind ( const int port );
bool listen() const;
bool accept ( Socket& ) const;
// Client initialization
bool connect ( const std::string host, const int port, int useproxy,std::string proxyhost,int proxyport);
// Data Transimission
bool send ( char *buf, int length ) const;
bool send ( const std::string ) const;
int recv ( std::string& ) const;
int recv ( char *buf, int maxlen ) const;
void set_non_blocking ( const bool );
bool is_valid() const { return true; }
int m_sock;
private:
sockaddr_in m_addr;
HANDLE netlibcon;
};
#endif
|