<html><body><div style="color:#000; background-color:#fff, font-family:times new roman, new york, times, serif;font-size:14pt">Hey!<br><br>Hope this is the right place to put this question...<br><br>I just want some little guidance on a small hobby game I am making atm...<br><br>Well first off I want to know if I am doing it right :) <br><br>Example: I have some test programs: client.exe and server.exe<br>I was quite clueless on how to make for ex: send a message from client to server and display on server...<br>I played around a bit and managed to make it work...<br><br>I did it like this (and here is where I want to know if I did it well and got things right)<br><br>Client.exe:<br><br>client = enet_host_create (....) //I create the client<br><br>enet_address_set_host
(& address, "xx.xx.xx.xx.xx");<br>address.port = 1234; <br>peer = enet_host_connect (client, & address, 2, 0); //connect<br>if (enet_host_service (client, & event, 5000) > 0 && event.type == ENET_EVENT_TYPE_CONNECT) {cout>>bla bla} //if connected display a message<br><br>and now small confusion: <br><br>while (enet_host_service (client, & event, 100) > 0)<br> { switch (event.type)<br> {<br> case A<br> case B etc...<br><br>I kinda know what this does... I think I must call enet_host_service("what the current exe is(client or server)", & event,100) just to make the transfer
between client and server ?<br>I mean without having this code in the client too, sending is not possible so I guess I must have it anyway. <br>moving on,<br><br>ENetPacket * packet = enet_packet_create (bla bla,strlen (bla bla) + 1, ENET_PACKET_FLAG_RELIABLE); //make packet <br> enet_peer_send (peer, 0, packet); //send it<br>call enet_host_service again so that the transfer is made.<br><br><br>And the Server.exe is: <br><br> enet_address_set_host (& address, "xx.xxx.xx.xx"); //set address of host<br>address.port = 1234;<br> server = enet_host_create (& address ,32,2,0,0); //create server<br><br>for(;;)<br> {update(); Sleep(10);}<br>where update() contains the whole:<br>"while (enet_host_service (client, & event, 100) > 0)<br>
{ switch (event.type)<br>
{<br>
case A<br>
case B etc..."<br><br>thing... So I make it listen for the client...<br>Anyway just wanted to know if this is the right principle for this library.<br>And also a small problem... given these 2 programs, when it should write the IP that connected to the client, it shows up numbers like "A new client connected from 15157e56:61514" where the last part after the : is the port, which I guess is displayed correctly... but the IP is not. What could be the problem ? The case ENET_EVENT_TYPE_CONNECT: is like in the tutorial. <br><br><br>Thanks for your attention,<br>Alex<br><br><br></div><br>
</body></html>