ANET; please save me!!

Posted By: xxGOTARxx

ANET; please save me!! - 03/14/09 17:57

after more than 24 hours of fumbling with 3dgsNET I decided to try out ANET. This is my new problem. I placed the .dll in the wedplugin folder. I put the anet.h file in my source code folder. I used #include "anet.h" I made an empty project just to see if i had my include set up correctly, it compiles fine but I never get the game screen it just exits.

Code:
 
#include <acknex.h>
#include <default.c>
#include "anet.h"

void main()
{
	wait(1000); //added just to see if anything poped up
}
 


Shouldnt this at least give me a blank screen and wait for me to hit ESC?
Posted By: Tobias

Re: ANET; please save me!! - 03/14/09 18:10

Yes, it should give you a blank screen because wait(1000) does nothing. But maybe something inside "anet.h" calls the sys_exit command immediately.

There is a whole workshop about multiplayer in the tutorial, so why don't you use that first for getting started?
Posted By: xxGOTARxx

Re: ANET; please save me!! - 03/14/09 18:16

I couldnt find ANET tutorials, I tried the GS ones but could never make a connection to my own server, even when using local instead of IP.
Posted By: Tobias

Re: ANET; please save me!! - 03/14/09 18:26

Then, I think you wont have any better luck with ANET.

When you give no IP, it connects with "localhost", which is just the same PC. For connecting with a different PC on the LAN, you must give its IP, which on a LAN always begins with 192.168. When youre a beginner and just want to start easy, run client and server on the same PC, then you dont need to care about the IP at all.
Posted By: xxGOTARxx

Re: ANET; please save me!! - 03/14/09 18:33

Yep, this I know, and that I did, for some reseason even after it finds the server it then tells me "no communication established."

Thanks for the replys Tobias smile
Posted By: Tobias

Re: ANET; please save me!! - 03/14/09 18:40

Hmm, maybe its some issue with the Directplay or winsock library on your PC, that would explain why ANET doesnt work either. I've done some tests with multiplayer some time ago and found that the internal network library and ANET are both pretty reliable.

Maybe you can post the acklog.txt that you get after starting with -diag, this could tell something about whats wrong with the communication and why ANET exits immediately.
Posted By: xxGOTARxx

Re: ANET; please save me!! - 03/14/09 18:52

I have other development software installed like visual c# express and Visual C++ do you think they might be causing a conflic?
Posted By: xxGOTARxx

Re: ANET; please save me!! - 03/14/09 19:19

Well to trouble shoot this I took the ANET tutorial program and put it on a different computer and the client and server would not connect again. That comp isnt set on a network so I know it was running local. This is making me insane... Can't understand what is going on.
Posted By: slacer

Re: ANET; please save me!! - 03/14/09 21:39

There are several things that come into play:
- firewall (Microsoft, Symantec, ZoneAlarm,...)
- the command line options you used to start client and server
- your code (did you try other published network apps created with gamestudio?)

until we know more about your system, we can only guess blindly
Posted By: xxGOTARxx

Re: ANET; please save me!! - 03/14/09 21:56

Thanks for the reply.

I have shut the firewall off and I am running no other anti-virus software.
I have tried starting the client with -cl -ip 127.0.0.1 -port 2300.
I have tried the code from ANET's 3d chat tutorial, also the SED tutorial 25 that deals with mp gaming.

The serves seams to be initializing just fine however the clients never find the server. I am about to break down and learn WinSock LoL!
Posted By: slacer

Re: ANET; please save me!! - 03/14/09 22:10

If you use gamestudio networking, you would not need to use the port.
And if you use the port on the client side, make sure the server is listening on that port, too.
You should launch both apps with -diag in order to create two logfiles to show here.
Posted By: xxGOTARxx

Re: ANET; please save me!! - 03/14/09 22:38

Ok here is what I am working with. Basically I am just trying to make a server, then make a client that connects to that server, once connected the enet_server_event kicks in and the server tells my that a client connected.

Code:
#include <acknex.h>
#include <default.c>
#include "anet.h"

STRING* str_message = "NULL";


void check_mode()
{
	if(enet_get_connection() == 0) {printf("No connection!");} 
	if(enet_get_connection() == 1) {printf("server!");} 
	if(enet_get_connection() == 2) {printf("client!");} 
	if(enet_get_connection() == 3) {printf("client-server!");} 
}


void start_server()
{
	enet_init();
	enet_init_server(2300,4,_str(""));
	str_cpy(str_message,"starting server");
	wait(500);
	check_mode();
}

void start_client()
{
	enet_init();
	enet_init_client(_str("76.215.138.102"),2300,_str(""));
	str_cpy(str_message,"starting client");
	wait(500);
	check_mode();
}

void sv_client_connected(var sender, STRING* msg) 
{ 
	printf("A new client connected!"); 
} 



void main()
{
	
	// Set Video Mode
	video_mode = 7;
	
	
	while(1)
	{
		if(key_s)
		{
			start_server();
			return;
		}
		
		if(key_c)
		{
			start_client();
			return;
		}
		
		wait(1);
	}
	
	while(1)
	{	
		enet_set_event(1,_str("sv_client_connected")); //sets the client connected event 
	}
	
	
}

TEXT* display = 
{
	string(str_message);
	flags = VISIBLE;
}

 


The following is the last -diag i got from the client

Log of A7 Engine 7.70.0 run at Sat Mar 14 17:35:53 2009
GotaR on Windows NT/2000/XP version 5.1 Build 2600
Options KAT.c -diag -tA

App C:\Program Files\GStudio7\acknex.exe in C:\Kingdoms at War\
MM mixer opened
DSOUND device opened
DI interface opened
Start Window opened
(c)Conitec . Dieburg . San Diego . www.3dgamestudio.com
A7 Engine - Trial Edition V7.70.0 - Feb 5 2009
Development version
26 days left

DI Microsoft PC-joystick driver 4 axes 8 buttons initialized
Mouse found
Joystick found
SB Live! Wave Device opened
NVIDIA GeForce 6200 pure T&L device 1ff9 detected
D3D device NVIDIA GeForce 6200 1ff9 selected.
ANet.dll opened
ackwii.dll opened
t7.dll opened
Compiling KAT.C - [Esc] to abort..... .... .. 0.467 sec
Running KAT.C.
2 objects
Main started at 2.635
def_startup started
anet_main_loop_startup started
D3D_Init Window: 800x600 -> Window: 1x800x600x32
Video memory found: 161 MB
Main loop at 2.760...
Server started at 2.761
Client started at 2.761.
1st frame with 161 MB at 2.789
Posted By: Spirit

Re: ANET; please save me!! - 03/15/09 09:50

enet_init_client(_str("76.215.138.102")...

Thats an Internet IP, so you connect over the Internet? Better use the local network at first, or even, run client and server on the same PC.

When you connect over the internet you must set port forwarding to your server in your router. Better dont start with complicated things before you got it running locally.

I would even start with 3DGS network before you try ANET. 3DGS network is easier to use, you need less commands. Once that works on your LAN then you can connect through Internet or try ANET.
Posted By: Dark_samurai

Re: ANET; please save me!! - 03/15/09 12:42

Quote:
I would even start with 3DGS network before you try ANET. 3DGS network is easier to use, you need less commands. Once that works on your LAN then you can connect through Internet or try ANET.


No! ANet needs less commands to send data and in my eyes it's much easier to understand. That's why I created it wink
If you want to send data with GS Network, you have to send it to the server and forward it to the client. ANet is doing all that for you.
The next plus is that you won't need to use the enoying command lines!
ANet offers you a lot of functions that would need a lot of time and understanding if you want to do the same with the GS networksystem.

@xxGOTARxx: There is an mistake in your main function! You program will never set the event! If you start a server or a client, the main program is shut down and won't call the enet_set_event() function smile Correct would be:

Code:
void main()
{
	
	// Set Video Mode
	video_mode = 7;
	
	enet_set_event(1,_str("sv_client_connected")); //sets the client connected event
	while(1)
	{
		if(key_s)
		{
			start_server();
			return;
		}
		
		if(key_c)
		{
			start_client();
			return;
		}
		
		wait(1);
	}	
}



Try to run this program:

Code:
#include <acknex.h>
#include <default.c>
#include "anet.h"

function client_connected(var sender, STRING* msg);

void main()
{
      level_load("");
      wait(3);
      enet_init();
      enet_set_event(1,_str("client_connected"));
      while(1)
      {
            if(key_s == ON) {enet_init_server(2300,4,_str(""));return;}
            if(key_c == ON) {enet_init_client(_str("localhost"),2300,_str("");return;}
            wait(1);
      }
}

function client_connected(var sender, STRING* msg)
{
    error("Client connected!");
}


You have to start the application 2 times (on the same computer!). First you have to open a server and after that you have to open a client. If everything works, on the server an error message will popup with the content "Client connected!".

Tell me if this is working for you.

You can also contact me on ICQ. My ICQ number is in my profil.

regards,
Peter


Posted By: Germanunkol

Re: ANET; please save me!! - 03/18/09 08:59

I was just about to start a new thread when I noticed this one. I get a very similar Problem when trying the Chat-Tutorial. Also, with the Pong demo, I have no luck.
In the Chat tutorial's LiteC version, I can start a host, then I start a client, type in "localhost" and then it just sits there and does nothing. Another thing I noticed that even when I start the host, I don't see the character that I chose, I only have the camera sitting just above the ground, like it's still at 0,0,0 without having moved to the position behind the character...
?
Posted By: Dark_samurai

Re: ANET; please save me!! - 03/18/09 14:48

Hmmm... maybe the dll isn't loaded.

Can you download this small program and tell me what it displays in the window on the bottom.

What GS Version do you use?
Posted By: Germanunkol

Re: ANET; please save me!! - 03/18/09 15:06

I was using LiteC, free version.
But for trying the simple_3dchat_1.1 I shouldn't need any 3dgs version installed, or do I?

yes, it seems like it can't open the dll:

"
...
anet_callback: function not found
anet_reset_queue: function not found
anet_set_compatibility: function not found
anet_set_encryption: function not found
anet_set_warning: function not found
enet_abort_fsending: function not found
enet_check_client: function not found
enet_clsend_event: function not found
enet_clsend_file: function not found
enet_connected_clients: function not found
enet_deinit: function not found
enet_destroy_host: function not found
enet_disconnect_client: function not found
enet_ent_create: function not found
enet_ent_creator: function not found
enet_ent_globpointer: function not found
enet_ent_locpointer: function not found
...
"

is what it says in the acklog.txt.
I just noticed that it may be my windows though, I think I need to reinstall it, it's messed up. There's other things that haven't been working, but I didn't associate it with that at first. Sorry, I'll try repairing my windows and then try again...


[edit] what's weird though is that my game that's based on GSTNET works fine, using a local host and local client... GSTNET.dll can be loaded...
[/edit]
Posted By: Dark_samurai

Re: ANET; please save me!! - 03/18/09 15:50

Seems like you don't have the VC++ 2008 redistributal package installed (which should be though!). You can download it here: http://www.microsoft.com/downloads/detai...;displaylang=en

This also explains why GSTNet (created with DEV Cpp) can be loaded smile
Posted By: Germanunkol

Re: ANET; please save me!! - 03/19/09 11:50

Hm...even with VC++ installed I can't get it to work. I just setup my whole PC anew because of the Virus I had. I get an Error E1512 Upon startup of the chat Multiplayer "Empty prototype called in main"
and still the same output in the acklog.txt...
Of course, since none of these funktions are loaded I still can't connect to a local host.
Posted By: Dark_samurai

Re: ANET; please save me!! - 03/19/09 14:11

Please download the Dependency Walker and open the dll with this program. After that tell me what it displays in the window on the bottom.
Posted By: Germanunkol

Re: ANET; please save me!! - 03/19/09 14:45

Ah, I'm sorry. I had it downloaded but totally forgot.
here you go:
"Error: The Side-by-Side configuration information for "h:\download\windows\3dgs\anet\anet_simple_3dchat_eng_1.1\anet_simple_3dchat_eng_1.1\lite-c\ANET.DLL" contains errors. Diese Anwendung konnte nicht gestartet werden, weil die Anwenungskonfiguration nicht korrekt ist. Zur Problembehebung sollten Sie die Anwendung neu installieren (14001).
Error: At least one required implicit or forwarded dependency was not found.
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module."

that's what I get when opening ANet (the one in the 3dgschat demo, liteC version) with dependency walker.
does that help?


above this it says "error opening file, the system can't find it" (or something like that, translated from german) to the following files:
MSVCR90D.DLL
EFSADU.DLL
MSJAVA.DLL

[edit]
Okay, found EFSADU.DLL and MSJAVA.DLL and downloaded them. but MSVCR90D.DLL seems to be a problem that many VC users have. All of them also had their projects on different partitions/drives than their main Windows folder. Same here, I have it on H: and Windows is on C:. But copying the project to C: doesn't help me at all...
[/edit]
Posted By: Dark_samurai

Re: ANET; please save me!! - 03/19/09 16:46

Download the ANet.dll again. You have an old version (this was a bug of 1.1.1.1). The latest version (1.1.2.1) fixes this bug.
Posted By: Germanunkol

Re: ANET; please save me!! - 03/19/09 20:35

It's working!! You were right, I just had to copy the dll from the demo into the chat-workshop's folder.
Thanks a lot smile
I'll check out these functions now... if this works out for us, maybe you'll have another sold copy soon smile
Posted By: Dark_samurai

Re: ANET; please save me!! - 03/20/09 12:16

Good to hear! smile

Just tell me, if you have problems again.
Posted By: Germanunkol

Re: ANET; please save me!! - 03/25/09 18:58

I ran into another problem:

enet_set_playername()
when I call this on the host (server AND client initialized. That part worked. I made sure enet_get_connection() returns 3 as well) then enet_get_clientid is -1, because it's a server, but enet_set_playername seems to work with the client id? which is then not a valuable one, cause it's negative?
Posted By: Dark_samurai

Re: ANET; please save me!! - 03/25/09 19:57

This can't be:

1) In Client-Server mode, enet_get_clientid() normally should return 0.
2) enet_set_playername() returns a warning if clientid is negative! (Did you turned of the warnings with anet_set_warning()?)

=> Either you display a wrong value or enet_set_playername() is called before the clientid is set to -1.

Do you use a password protected server? Because there is a bug in the current version that always disconnects the client even if a correct password is sent.
(Fixed in 1.2.1.1 that will be released soon with more new features wink ).

Can you post your code?
Posted By: Germanunkol

Re: ANET; please save me!! - 03/26/09 14:23

again, my bad.
I missed this:
"ATTENTION: The client gets its clientid after the connection with the server is established. => the clientid is NOT immediately available after initializing the client! "
(how could I miss it? the ATTENTION is bold AND in capitals...)
Now the clientId is correct.

but the program still doesn't work.

Code:
void startupHost()
{
	initEvents();
	var initResult=0;var initResult2=0;
	initResult = enet_init_server(port,maxPlayers,_str(""));
	initResult2 = enet_init_client((userData.pstring)[2],port,_str(""));
	if(initResult == 1 && initResult2 == 1)
	{
		logNewMessage("--Server started. Connected as Client.");
		wait(15);		//wait for clientid to be set
		wait(-1);
		my_temp[1] = enet_get_clientid();
		STRING* playername = str_create("testname");
		enet_set_playername(playername);
	}
	else
	{
		logNewMessage("--Could not connect. Exiting.");
		sys_exit("NULL");
	}
}



in main:
	wait(-2);
		STRING* tmpPlayerNameStr = str_create("");
		var result1;
	result1 = enet_get_playername(enet_get_clientid(),tmpPlayerNameStr);
	if(result1 == -1)beep();
	str_cpy((userData.pstring)[0],tmpPlayerNameStr);


It beepes (or beep();es). I tried, as you can see, various waiting times..
it seems to give back an empty string or something in enet_get_playername, because if I copy it into the userData text, the string in the userData text seems to be deleted, resulting in the strings [1], [2] and so on to be moved upwards.

Is there any way to say how long exactly I have to wait untill the clientId is set? I do get the error message "no clientId" if I don't wait 5 frames after the client initialization. just like the manual states. but how long do I have to wait? does it depend on the connection?

What makes it even more confusing is that this:
Code:
	wait(-2);
	STRING* tmpPlayerNameStr = str_create("testname");
	enet_set_playername(tmpPlayerNameStr);
	str_cpy(tmpPlayerNameStr,"            ");
	var result1;
	result1 = enet_get_playername(enet_get_clientid(),tmpPlayerNameStr);
	if(result1 == -1)beep();
	str_cpy((userData.pstring)[0],tmpPlayerNameStr);

makes it work (all called in one go, inside main, so enet_set_playername is not in the same function as enet_init_client), but when I pass an empty string (str_cpy(tmpPlayerNameStr," "); replaced by str_cpy(tmpPlayerNameStr,"");) it crashes the program.


sorry, I'm confused...O.o


another update: In the chat-demo-tutorial I found that calling wait(4); between initializing a server and a client (on the same machine) is a good thing. I didn't yet because in the manual I found this:

Code:
void start_clientserver() 
{ 
//Client-Server Modus: 
enet_init_server(2300,4,_str("")); //Initializes the server 
enet_init_client(_str("127.0.0.1"),2300,_str("")); //Initializes a client 
//which connects over the localhost with the server 
} 

without wait(4). If I DO wait(4);, then I got a "bad client id in enet_get_playername". Of course, now that I'm typing this I can't recreate that error message, it's back to as it was before: string gets deleted from the text...
Posted By: Dark_samurai

Re: ANET; please save me!! - 03/26/09 16:36

Quote:
Is there any way to say how long exactly I have to wait untill the clientId is set?


Yes, the clientid is set after the connected with server event is called or you put a while(enet_get_clientid() == -1) {wait(1);} into your code wink

Normally you start the client and a little bit later the connected with server event is called and from here you start the functions that control your game. Then you can be sure that the connection is set up correctly.

This should solve your problems. A howto of correct setting up a connection is already added to the new manual which will be released with the new version.

Code:
void start_clientserver() 
{ 
//Client-Server Modus: 
enet_init_server(2300,4,_str("")); //Initializes the server 
enet_init_client(_str("127.0.0.1"),2300,_str("")); //Initializes a client 
//which connects over the localhost with the server 
} 


This code only initializes a server and then a client and doesn't meen that the clientid is available after the client is initialized.
Posted By: Germanunkol

Re: ANET; please save me!! - 03/27/09 18:09

Okay, I'm getting there.
It's working now, sending and receiving, and I'm sort of getting what I want (only after looking very closely at the chat-demo though, maybe I'm just... stupid -.-)
The problem that I'm having most of the time that all liteC tells me is "crash in...", which is not being very helpful.

"ATTENTION: In the client/server mode the event is called twice! Once for the server and once for the client! "
there's no workaround for this...?
I mean, the host doesn't know whether this event has already been received by him or not...
I just get all chat messages twice on the host...
and I can't figure out how the chat-demo does it...

Sorry, again, piling up the questions. I just wanna get these basics down, thanks to you I've gotten MUCH further.

[edit] oh, and a feature request: could you make enet_get_playername accept empty strings somehow? I had quite a few crashes because I did this at first:
STRING* tmpPlayerName = str_create("");
enet_get_playername(senderorsomeone,tmpPlayerName);

this:
Code:
STRING* tmpPlayerName = str_create("          ");
enet_get_playername(senderorsomeone,tmpPlayerName);

works fine though.
Since the program just quits it was very hard to find that bug.
[edit]
Posted By: Dark_samurai

Re: ANET; please save me!! - 03/27/09 19:29

Quote:
The problem that I'm having most of the time that all liteC tells me is "crash in...", which is not being very helpful.


Therefor the warning system of ANet is implented. In theory it should turn all crashes into warnings that should help you to find the problem easier.

Can you tell me some of the crashes you had, so I can add a warning?

Quote:
"ATTENTION: In the client/server mode the event is called twice! Once for the server and once for the client! "


Hehe I'm a bit faster than you. It's already changed wink
The event system is now much clearer designed.

I hope that I can release the new version at the end of this weekend.

Quote:
could you make enet_get_playername accept empty strings somehow?


Why don't you just initialize the string with 30 chars? I think I will add a warning for this, but it makes no sence for me to support empty strings.
Posted By: Germanunkol

Re: ANET; please save me!! - 03/28/09 08:57

all right, that's cool smile... looking forward to that new version laugh
I really did get it working now, it's just funny that the host displays every chat message twice laugh

The 30 char thing is fine, I can do that and I was going to, but an error message would be nice there, that was one of the things that crashed.
I forgot the other ones though. If I run across them again (which I sure hope I don't :P) I'll tell you. I guess most of them were because of bad coding though, because I'm learning liteC and Anet at the same time, so far I've only used Cscript... and it was always hard to tell whether it was my code or Anet that crashed O.o

thanks, and have fun coding that new version :P
© 2024 lite-C Forums