<html><head></head><body>1,2,3: yes<br>
try simple enet-only example code same machine.<br>
bonus: search for ENET_wrapper.hpp for nice c++ example.<br><br><div class="gmail_quote">On December 12, 2017 5:08:35 PM GMT+01:00, Ian Badcoe <ian_badcoe@yahoo.co.uk> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div>Hi,</div><div><br /></div><div>I'm trying to create a prototype game using enet for networked play.</div><div><br /></div><div>I am creating the host and client very similarly to what is shown in the tutorial, but I cannot get the client to connect to the server. So far, this is all on the same machine... A client should be able to find a server on the same machine, shouldn't it?</div><div><br /></div><div>I have tried adjusting the port and address settings in many different ways in an attempt to make it work but everything fails the same way, e.g. the "enet_host_service" call that I make after "enet_host_connet" times out without generating any event.</div><div><br /></div><div>My code is quite large (because I have integrated enet into the existing non-networked codebase) but what is done with enet is pretty simple (and even simpler during this initial phase...)</div><div><br /></div><div>The host was created like this:</div><div><br /></div><div> ENetAddress address;<br /><br /> address.host = ENET_HOST_ANY;<br /> address.port = 1234;<br /> _data->_enet_host = enet_host_create(<br /> &address,<br /> 32,<br /> 2,<br /><div> 0, 0);</div><div><br /></div><div>and then goes into a loop which calls enet_host_service continually:</div><div><br /></div><div> int ret = enet_host_service(_data->_enet_host, &event, 5);<br /><br /><div>-----<br /></div><div><br /></div><div>The client was created like this:</div><div><br /></div><div> _data->_enet_host = enet_host_create(<br /> NULL,<br /> 1,<br /> 2,<br /> 0, 0);<br /><br /> if (!_data->_enet_host)<br /> {<br /> ...<br /> }<br /><br /> int ret;<br /> ENetAddress address;<br /> address.host = ENET_HOST_BROADCAST;<br /> address.port = _data->_port;<br /><br /> _data->_enet_peer = enet_host_connect(_data->_enet_host, &address, 1, 0);<br /><br /> if (_data->_enet_peer == NULL)<br /> {<br /> ...<br /> }<br /><br /> ENetEvent event;<br /><br /> ret = enet_host_service(_data->_enet_host, &event, 5000);<br /><br /><div> if (ret > 0 && event.type == ENET_EVENT_TYPE_CONNECT)</div><div> {</div><div> ... <- we never get here and "ret" is always zero<br /></div><div> }<br /></div><div><br /></div><div>-----</div><div><br /></div><div>I have tried a lot of possibilities for the address and port settings, addresses including:</div><div><br /></div><div>127.0.0.1</div><div>ENET_HOST_ANY (host)<br /></div><div>ENET_HOST_BROADCAST (client)<br /></div><div>local ip<br /></div><div><br /></div><div>and various ports such as 55555 or 5432</div><div><br /></div><div>but nothing seems to work. I am compiling for x64 on windows using VC2017. Enet is running in its own thread, and I have been careful with a critical_section for the parts that need it, but the program is not getting far enough to reach any thread<->thread issues yet... </div><div><br /></div><div>My problem is I don't know where the problem might lie:</div><div><br /></div><div>1) can Enet work on a single machine?</div><div>2) can ENET_HOST_BROADCAST work on a single machine?</div><div>3) can it be network settings / firewall (I doubt this since in the past I have done a lot of general client server work from VMs hosted on this same machine without any difficulty...)</div><div><br /></div><div>I basically need some hint on where to look for the problem... Does Enet have some sort of verbose mode that will log problems to the debug stream?</div><div><br /></div><div>Thanks for any help, I did try looking in the mail-list archives but my problem is not really knowing what to search for...</div><div><br /></div><div>Later I will try again at home, which should eliminate network/firewalls as a possibility...</div><div><br /></div><div>Thanks again,</div><div><br /></div><div>Ian<br /></div><br /></div></div><br /><br /></div></div></blockquote></div></body></html>