[ENet-discuss] Problem partailly solved

Jay Sprenkle jsprenkle at gmail.com
Mon Feb 28 07:22:57 PST 2011


I assumed he was trying to do something like this:

    /* Create a reliable packet of size 7 containing "packet\0" */
    ENetPacket <http://enet.bespin.org/struct__ENetPacket.html> *
packet = enet_packet_create
<http://enet.bespin.org/group__Packet.html#gac61b251aebbf9f5e5e313eca51339ea>
("packet",
                                              strlen ("packet") + 1,

ENET_PACKET_FLAG_RELIABLE
<http://enet.bespin.org/enet_8h.html#9d1fc0ce6da0a057f18bd8b9c762003dab20e7088245ab2ddb7f11dcc9433738>);



On Mon, Feb 28, 2011 at 8:23 AM, Ruud van Gaal <ruud at racer.nl> wrote:

> No packet is being sent indeed.
> The peer->data is a local pointer that only 'lives' at the computer that
> defines it. Nothing is send; you need packets for that. It's just to
> associate computer-local data with the peer (a peer is a computer, not a
> packet).
>
> Ruud
>
>
> On Mon, Feb 28, 2011 at 2:10 PM, Nuno Silva <little.coding.fox at gmail.com>wrote:
>
>> There's no packet size for peer data (at least from what the docs tell me
>> about the _ENetPeer struct), since he's probably not sending a packet. He's
>> just setting the peer's data to the name, not a packet's data.
>>
>> On Mon, Feb 28, 2011 at 12:55 PM, Jay Sprenkle <jsprenkle at gmail.com>wrote:
>>
>>> Some quick comments. See below:
>>>
>>> On Mon, Feb 28, 2011 at 5:32 AM, Alexaroth <alex_prislopeanu at yahoo.com>wrote:
>>>
>>>> Well I kinda understand how things work... the thing is this
>>>>
>>>> I have some client code:
>>>>
>>>> peer = enet_host_connect (client, & address, 2, 0);
>>>> name =  player.getname();    //this returns a string from inside a class
>>>> member
>>>> peer->data = (void*)name.c_str();  I am making the peer data the name of
>>>> the player
>>>>
>>>>
>>> I assume you set the packet size to the size of the name string ?
>>>
>>>
>>>
>>>
>>>>
>>>> On the server end:
>>>>
>>>> ENetPeer *peer2[2];
>>>>
>>>> while (enet_host_service (server, & event, 100) > 0)
>>>>     {   switch (event.type)
>>>>         {
>>>>         case ENET_EVENT_TYPE_CONNECT:
>>>>
>>>>             peer2[1] = event.peer;
>>>>             textprintf_ex(screen, font, 10, 200, white,-1,"%s is client
>>>> !",peer2[1]->data);   this is allegro, it just outputs the %s is client on
>>>> screen
>>>>             name=(char*)peer->data;
>>>>
>>>>
>>> You're using a pointer here instead of copying the data from the enet
>>> packet.  Make sure you aren't using deleted data or just losing memory by
>>> not destroying packets.
>>>
>>> Shouldn't this:
>>> name=(char*)peer->data;
>>>
>>> be this:
>>> name=(char*)peer2[1]->data;
>>>
>>>
>>>
>>> _______________________________________________
>>> ENet-discuss mailing list
>>> ENet-discuss at cubik.org
>>> http://lists.cubik.org/mailman/listinfo/enet-discuss
>>>
>>>
>>
>> _______________________________________________
>> ENet-discuss mailing list
>> ENet-discuss at cubik.org
>> http://lists.cubik.org/mailman/listinfo/enet-discuss
>>
>>
>
> _______________________________________________
> ENet-discuss mailing list
> ENet-discuss at cubik.org
> http://lists.cubik.org/mailman/listinfo/enet-discuss
>
>


-- 
---
"The great thing about Object Oriented code is that it can make small,
simple problems look like large, complex ones."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubik.org/pipermail/enet-discuss/attachments/20110228/45352dff/attachment.html>


More information about the ENet-discuss mailing list