Used a sockaddr_storage struct instead of a sockaddr struct, since the latter is not big enough for IPv6
This commit is contained in:
@@ -23,7 +23,7 @@ protected:
|
|||||||
int port;
|
int port;
|
||||||
int sock_fd;
|
int sock_fd;
|
||||||
std::string address;
|
std::string address;
|
||||||
struct sockaddr* dest;
|
struct sockaddr_storage* dest;
|
||||||
socklen_t addrlen;
|
socklen_t addrlen;
|
||||||
int other_socket; // The peer socket (the client if this socket is a server, and the server if this socket is a client) */
|
int other_socket; // The peer socket (the client if this socket is a server, and the server if this socket is a client) */
|
||||||
|
|
||||||
|
4
sock.cpp
4
sock.cpp
@@ -8,7 +8,7 @@
|
|||||||
extend this function, and create the appropriate sockets. */
|
extend this function, and create the appropriate sockets. */
|
||||||
|
|
||||||
void Sock::create_socket() {
|
void Sock::create_socket() {
|
||||||
dest = (struct sockaddr *)malloc(sizeof(struct sockaddr));
|
dest = (struct sockaddr_storage *)malloc(sizeof(struct sockaddr_storage));
|
||||||
addrlen = sizeof(*dest);
|
addrlen = sizeof(*dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ This function also needs more testing for TCP. */
|
|||||||
char* Sock::recvAll() {
|
char* Sock::recvAll() {
|
||||||
int num_bytes_received = 0;
|
int num_bytes_received = 0;
|
||||||
int total_bytes_received = 0;
|
int total_bytes_received = 0;
|
||||||
char* buffer = (char *)malloc(150);
|
char* buffer = (char *)malloc(150 * sizeof(char));
|
||||||
bool has_been_read = false;
|
bool has_been_read = false;
|
||||||
|
|
||||||
if (this->protocol == ES_UDP) {
|
if (this->protocol == ES_UDP) {
|
||||||
|
Reference in New Issue
Block a user