Sign in to follow this  
elsharkawey

error: ‘struct RakNet::SocketDescriptor’ has no member named ‘socketFamily’|

Recommended Posts

when i run my client code i get this error i using code::blocks and im linux system in the tutorial that i follow the code working without any errors my includes files in the project

#include "MessageIdentifiers.h"
#include "RakPeerInterface.h"
#include "RakNetStatistics.h"
#include "RakNetTypes.h"
#include "NetworkIDObject.h"
#include "NetworkIDManager.h"
#include "BitStream.h"
#include "RakSleep.h"
#include "WindowsIncludes.h"
#include "PacketLogger.h"
the error: ‘struct RakNet::SocketDescriptor’ has no member named‘socketFamily’| in the line 39 in the client.cpp file

client.h file

#include "raknetincludes.h"
#include "irrlicht.h"


class Client
{
private:
int numSockets;
int numIPs;
int maxPlayers;
unsigned char packetIdentifier;

RakNet::SocketDescriptor socketDescriptor;
RakNet::NetworkIDManager networkIDManager;
RakNet::NetworkID playerNetworkID;
RakNet::MessageID typeID;
RakNet::Packet *p;

unsigned char GetPacketIdentifier(RakNet::Packet*p);

public:
Client(int=8);
void CreateClientInterface();
void SetIP();
void ClientStartup();
void ShutDownClient();
void ReceivePackets();

RakNet::RakPeerInterface *client;

std::string serverPort;
std::string clientPort;
std::string serverIP;

};

client.cpp file

#include "client.h"
#include "customnetworkenums.h"
#include "raknetincludes.h"
#define DEBUG_BUILD

Client::Client(int maxPlay)
{

maxPlayers = maxPlay;

serverPort = "6001";


}
void Client::CreateClientInterface()
{

client = RakNet::RakPeerInterface::GetInstance();
if(!client){


}
RakNet::SystemAddress clientID = RakNet::UNASSIGNED_SYSTEM_ADDRESS;


}

void Client::SetIP()
{
serverIP= "127.0.0.1";
clientPort = "6000";
}

void Client::ClientStartup()
{
socketDescriptor = RakNet::SocketDescriptor(atoi(clientPort.c_str()),0);


socketDescriptor.socketFamily = AF_INET;
client->Startup(8,&socketDescriptor,1);
client->SetOccasiona1Ping(true);
RakNet::ConnectionAttemptResult car = client->Connect(serverIP.c_str(),atoi(serverPort.c_str()),"yoyo", (int)strlen("yoyo"));
RakAssert(car==RakNet::CONNECTION_ATTEMPT_STARTED);


}

void Client::ReceivePackets() {

for(p=client->Receive();p; client->DeallocatePacket(p), p=client->Receive())
{
packetIdentifier = GetPacketIdentifier(p);
//RakNet::BitStream bsIn(p->data,p->length,false);
//RakNet::BitStream bsOut;

switch (packetIdentifier){

case ID_DISCONNECTION_NOTIFICATION:
printf("ID_DISCONNECTION_NOTIFICATION from %s\n", p->systemAddress.ToString(true));
break;

case ID_ALREADY_CONNECTED:
printf("ID_ALREADY_CONNECTED\n");
break;

case ID_NEW_INCOMING_CONNECTION:
break;

case ID_INCOMPATIBLE_PROTOCOL_VERSION:
printf("ID_INCOMPATIBLE_PROTOCOL_VERSION\n");
break;

case ID_REMOTE_DISCONNECTION_NOTIFICATION:
printf("ID_REMOTE_DISCONNECTION_NOTIFICATION\n");
break;

case ID_REMOTE_NEW_INCOMING_CONNECTION:
printf("ID_REMOTE_NEW_INCOMING_CONNECTION\n");
break;

case ID_CONNECTION_BANNED:
printf("you are banned from this server\n");

break;
case ID_CONNECTION_ATTEMPT_FAILED:
printf("connection attempt field \n");
break;

case ID_CONNECTION_LOST:
printf("ID_CONNECTION_LOST from %s\n",p->systemAddress.ToString(true));
break;

case ID_NO_FREE_INCOMING_CONNECTIONS:
printf("sorry, the server is full \n");
break;
case ID_INVALID_PASSWORD:
printf("Acces Denied : inccorrect client password\n");
break;
case ID_CONNECTION_REQUEST_ACCEPTED:
printf("your connection has been accepted to %s with gud %s\n",p->systemAddress.ToString(true), p->guid.ToString());
break;
case ID_SPAMN_PLAYER:


break;


default:

break;










}



}

unsigned char Client::GetPacketIdentifier(RakNet::Packet*p)
{
if(p==0)
return 255;

if((unsigned char)p->data[0] == ID_TIMESTAMP)
{
RakAssert(p->length > sizeof (RakNet::MessageID)+sizeof(RakNet::Time));
return (unsigned char) p->data[sizeof(RakNet::MessageID)+ sizeof(RakNet::Time)];

} else
return (unsigned char) p->data[0];




}


void Client::ShutDownClient()
{

client->Shutdown(300);
RakNet::RakPeerInterface::DestroyInstance(client);

}

Share this post


Link to post
Share on other sites

Did you check the headerfile of RakNet::SocketDescriptor? The member is in there?

 

Maybe its just a weird follow up error from something else, like missing include guards etc.?

Share this post


Link to post
Share on other sites
Have you verified that the documentation you are looking at and the headers you are including actually match? Since the documentation you linked is from 2012 it is reasonable to assume that RakNet has evolved in the meantime and the data member no longer exists.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this