[ENet-discuss] WSAEINVAL error

Milan Sanger milan.sanger at hotmail.de
Mon Jun 9 03:39:48 PDT 2014


e.g. this is one i used:


#include <enet/enet.h>
#include <stdio.h>
#include <string.h>

int main(int argc, char **argv)
{
    ENetAddress address;
    ENetHost *client;
    ENetPeer *peer;
    char message[1024];
    ENetEvent event;
    int eventStatus;

    // a. Initialize enet
    if (enet_initialize() != 0) {
        fprintf(stderr, "An error occured while initializing ENet.\n");
        return EXIT_FAILURE;
    }

    atexit(enet_deinitialize);

    // b. Create a host using enet_host_create
    client = enet_host_create(NULL, 2, 57600/8, 14400/8);

    if (client == NULL) {
        fprintf(stderr, "An error occured while trying to create an ENet server host\n");
        exit(EXIT_FAILURE);
    }

    enet_address_set_host(&address, "localhost");
    address.port = 5119;

    // c. Connect and user service
    peer = enet_host_connect(client, &address, 2);

    if (peer == NULL) {
        fprintf(stderr, "No available peers for initializing an ENet connection");
        exit(EXIT_FAILURE);
    }

    eventStatus = 1;

    while (1) {
        eventStatus = enet_host_service(client, &event, 50000);

        // If we had some event that interested us
        if (eventStatus > 0) {
            switch(event.type) {
                case ENET_EVENT_TYPE_CONNECT:
                    printf("(Client) We got a new connection from %x\n",
                            event.peer->address.host);
                    break;

                case ENET_EVENT_TYPE_RECEIVE:
                    printf("(Client) Message from server : %s\n", event.packet->data);
                    // Lets broadcast this message to all
                    // enet_host_broadcast(client, 0, event.packet);
                    enet_packet_destroy(event.packet);
                    break;

                case ENET_EVENT_TYPE_DISCONNECT:
                    printf("(Client) %s disconnected.\n", event.peer->data);

                    // Reset client's information
                    event.peer->data = NULL;
                    break;
            }
        }

        printf("Say > ");
        gets(message);

        if (strlen(message) > 0) {
            ENetPacket *packet = enet_packet_create(message, strlen(message) + 1, ENET_PACKET_FLAG_RELIABLE);
            enet_peer_send(peer, 0, packet);
        }
    }
}






But it only gets to “eventStatus = enet_host_service(client, &event, 50000);”  and returns -1 everytime because of this error.





Von: Kazin Lujan
Gesendet: ‎Montag‎, ‎9‎. ‎Juni‎ ‎2014 ‎09‎:‎13
An: enet-discuss at cubik.org





Can you show an example in order to reproduce this error?




On Sun, Jun 8, 2014 at 7:16 PM, Milan Sanger <milan.sanger at hotmail.de> wrote:




Everytime I get the WSAEINVAL error in enet_socket_receive when I’m using the Client. The Server has no Problems at all.

I used different sources in the web but noone worked for me.
Using Version 1.2.5 and cant upgrade to a higher Version due to serveral reasons.




Please help me.










_______________________________________________
ENet-discuss mailing list
ENet-discuss at cubik.org
http://lists.cubik.org/mailman/listinfo/enet-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubik.org/pipermail/enet-discuss/attachments/20140609/2278a58b/attachment-0001.html>
-------------- next part --------------
_______________________________________________
ENet-discuss mailing list
ENet-discuss at cubik.org
http://lists.cubik.org/mailman/listinfo/enet-discuss


More information about the ENet-discuss mailing list