Advertisement

enet: hosting and connecting

Started by October 18, 2004 10:47 PM
10 comments, last by GameDev.net 20 years, 3 months ago
I'm trying to make two simple programs using enet- one that creates a server and another program to join it. It seems like the program that connects is working ok because it will connect if the server is running. However, the server program doesn't seem to ever recognize anything is trying to connect. And if I close the connecting program and run it again it doesn't connect- only the first time both programs are run. the server: http://members.aol.com/langjohnf/host.cpp the connecting program: http://members.aol.com/langjohnf/connect.cpp thanks for any help
im not sure, but i think it could be the way your setting the host address of the server. You do this:

enet_address_set_host (& address, "169.254.193.123");

try doing this instead:

address.host = ENET_HOST_ANY;

this is the equivalent of setting the IP to "127.0.0.1", IE your self. im not sure though, but i think you might have to set the


hmm, i just realized that this is probably your IP address and that means your setting it to yourself anyway. so ignore that, but i would still try it to just be safe.

i looked through your code but couldnt find any problems. heres an example of a working chat program that jack_1313 had showed me when i first started that helped. maybe it will help you. jack, i hope you dont mind.
FTA, my 2D futuristic action MMORPG
Advertisement
Argh… Gamedev.net is *supposed* to log me in automatically. :P

Jackson Allan
Just for your edification, I had a situation where I tried to run Enet on my ISP's linux machine where I needed to bind to an address. I figure that the machine had multiple interfaces and needed a hint.

Dunno if eal is in that situation though...
thanks for all the help, pretty much everything is working now
except for the fact that the server doesn't acknowledge anyone
is trying to connect. The server obviously works, but isn't it
supposed to generate an ENET_EVENT_TYPE_CONNECT message when
someone connects?

(i updated the source some)

the server:
http://members.aol.com/langjohnf/host.cpp

the connecting program:
http://members.aol.com/langjohnf/connect.cpp
yes, you *should* be recieving that on the server's end when a client connects.. whats with this?

				case ENET_EVENT_TYPE_CONNECT:					printf("\nconection established");					enet_host_destroy(server);						getchar();					atexit (enet_deinitialize);					return 1;					break;


why are you destroying the server here, and putting the atexit and return here? actually, im guessing this is just debugging stuff.... sorry i cant be anymore helpfull, ill look at your code some more though.

EDIT: one thing stuck out at me.. on the client side, try running an empty loop after connecting instead of immedately closing the program / connection. that might be causing you troubles.
FTA, my 2D futuristic action MMORPG
Advertisement
yeah, i just want it to acknowledge something connected. this
is the first enet\network program i've ever writen so it's just
a test thing. still doesn't work though...
Quote:

I’ve quoted myself from this thread that may very well be of interest to you. If need be, I suggest that you read through it as some common starting questions are cleared up etc.


That is supposed to be this thread. Gamedev.net just will not let me be! It does not address your problem however.

Jackson Allan
Quote:
Original post by Anonymous Poster
I'm having the same trouble. I've followed code from several tutorials, and the server refuses to acknowledge anything. I'm starting to believe the enet just doesn't work on some machines..as crazy as it sounds. I was hoping to come up with some platform portable code and free myself from winsock, but prospects are starting to look bleak. Every cross-platform library I try has been so poorly documented.

Does anyone have some full code to initiate a basic connect and packet send ? If I could find something like that, I could finally confirm that its not just some silly error I made and overlooked 10,234,233 times.


you my friend, need to discover raknet. i started out usng eNet, but found that there wasnt much support for it (the newsgroup for it is pretty much dead). rakknet has absolutely the best documentation for any library i've ever used. seriously. also, the creater is constantly updating the code and helping people with their problems in the forums. its a very full featured library and i personally love it. eal might want to check out the same, if his problems persist.

also, check out the forum FAQ, it has a list of API's you can check out, theres other good ones besides rakknet. you also might want to consider sticking with enet and trying their mailing list. good luck.
FTA, my 2D futuristic action MMORPG

This topic is closed to new replies.

Advertisement