-
Notifications
You must be signed in to change notification settings - Fork 0
/
Connection.h
50 lines (43 loc) · 1.22 KB
/
Connection.h
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
#ifndef CONNECTION_H
#define CONNECTION_H
#include <iostream>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include "SocketException.h"
using namespace std;
/**
* \brief Klasa modelujaca polaczenie majace na celu uzyskanie danych do bufora.
*
* \author Przemyslaw Piorkowski <piorkowskiprzemyslaw@gmail.com>
*/
class Connection
{
private:
/**< deskryptor gniazda */
int mySocket;
/**< dlugosc bufora danych */
int bufferLength;
/**< wskaznik na bufor danych */
unsigned char * buffer;
/**< struktura opisujaca adres naszej maszyny */
sockaddr_in myAddress;
/**< struktura opisujaca adres maszyny nadawczej */
sockaddr_in otherAddress;
/**< dlugosc struktury dla naszej maszyny */
socklen_t myAddressLength;
/**< dlugosc struktury dla maszyny nadawczej */
socklen_t otherAddressLength;
public:
Connection(int port, int bufferLength) throw(SocketException);
~Connection();
int receiveData();
unsigned char * getBuffer();
};
#endif // CONNECTION_H