Message Board
Message Board > Fenix / Bennu / Gemix / DIV > [DLL] Network.DLL |
August 7, 2006, 04:08 | |
Sandman
F3n!x0r 1194 posts |
Quoting Rhovanion: I can't change my nick and no one can see me type... any ideas? :o Kick Ecko. ____________ BennuWiki Yes, my avatar has grey borders in IE (so get a decent browser) ROOFLEZ ROOFLEZ |
# |
August 7, 2006, 19:34 | |
Rhovanion
Exterminated 666 posts |
Quoting Ariel Yust: Yeepee !!! hi there dudes...btw that program was coded realy well good job ecko I thought you were killed by those hezbollah losers or something! Glad to see ur alive!
____________ |
# |
August 8, 2006, 00:12 | |
Sandman
F3n!x0r 1194 posts |
Hm I keep updating network.dll these days. I think I'll have a break now. Version 1.17 v1.17: - Fixed seperation not working when seperatorlength is not 2. - Fixed no console reports of incoming messages when seperation is activated. - Fixed NET.Incoming[conn] not becoming NET_STATUS_ESTABLISHED when there is a message immediately. - Removed Internal connection type, as it's obsolete, since External connections have message splitting now too. Quoting Rhovanion: I thought you were killed by those hezbollah losers or something! Glad to see ur alive! :moustache: I won't start a debate about that war, but it seems Israel is allowed, by a UN resolution, to stay in Lebanon's land for the time being. Now is this ridiculous or what? America has been pro-Israel for a long time now and Bush keeps protecting them and making excuses for them. However, we will discuss this in a different thread, if anyone should have this desire.
____________ BennuWiki Yes, my avatar has grey borders in IE (so get a decent browser) ROOFLEZ ROOFLEZ |
# |
August 8, 2006, 01:09 | |
Rhovanion
Exterminated 666 posts |
discuss it further here for the sake of net.dll not to look foul because of war and blood.
____________ |
# |
August 8, 2006, 21:11 | |
Sandman
F3n!x0r 1194 posts |
Minor patch. Version 1.17a 117a:Fixed difference in behaviour when NET_Open() is used before the NET Switch() and after. Removed NET_STATUS_EXPECTINGPONG. Added NET_STATUS_ESTABLISHING and NET_STATUS_DISCONNECTING. ____________ BennuWiki Yes, my avatar has grey borders in IE (so get a decent browser) ROOFLEZ ROOFLEZ |
# |
August 8, 2006, 22:17 | |
Eckolin
Quite Whiskered 388 posts |
Excuse me for not upgrading to the latest version. My chatroom is working perfectly now -- if it isn't broken, don't fix it. New features when I find the courage to try them. ____________ Maker of Games... Wisdom is supreme; therefore get wisdom. Need help with coding? I probably wrote something similar. |
# |
August 8, 2006, 23:57 | |
Rhovanion
Exterminated 666 posts |
it always types in qwerty, fix it please
____________ |
# |
September 11, 2006, 14:28 | |
moi
Beardless 8 posts |
hi I'm new here, I just registered because of this networkd.dll. Sandman deserves a lot of kudos for his lib and the excellent description! Nevertheless i still have some problems. The first one is about having a working input prompt in fenix. Since I don't know of any existing, I had to write my own. The result worked in a quite primitive way: The main loop checks if any key is pressed, if yes it calls a process that gets a char as a parameter and adds this to an existing string, and then waits for some time to avoid the char being added more than one time. Here is a code snippet: main loop: Code: if(key(_a)) taste("a"); END if(key(_b)) taste("b"); END .... etc here the process that adds the characters to the string: Code: process taste(string taste) private pressed=0; begin if(pressed==0) globalstring+=taste; //the textstring gets a character added pressed=1; //only one char, per pressed key end For(timepl=0;timepl<fps*0.2;timepl++) Frame; //waiting 0.2 seconds, before new chars are allowed End pressed=0; //allow new chars to be added end Well this code works, but it sucks big time... sometimes chars are still added twice, sometimes chars are ignored. Is there a way to do this in a better way? ---------------------------------------------- My second problem is about sending and receiving INTs(I got it to work with strings flawlessly). Well sending is not that of a problem: I have a process that gets an INT and sends it to the client: Code: process senddata(int ballx) begin NET_SendVar( netid , &ballx , sizeof(ballx) ); end But receiving doesn't work yet. In the console a can see how the data is received but my INT variable doesn't get the values shown in the console. Code form the main loop of the client: Code: If (Net.incoming[1]==NET_STATUS_ACTIVE or Net.incoming[1]==NET_STATUS_ESTABLISHED) //getting the variable doesn't work yet ballx=NET_RecvVar( netid , &ballx , sizeof(ballx) ); end Any help is highly appreciated, since I've spent hours on fixing this without success, so it seems i found my limits ____________ |
# |
September 11, 2006, 16:33 | |
DTM
Earthling! 821 posts |
to get the keys you can use the "ascii" variable Code: if (ascii != 0) taste(chr(ascii)) ; end or if (ascii >= 32 && ascii <= 126) mystr += chr(ascii) ; while (ascii > 0) frame; end end don't know about the rest [Edited on September 11, 2006 by DTM] ____________ :o |
# |
September 11, 2006, 18:02 | |
moi
Beardless 8 posts |
Quoting DTM: to get the keys you can use the "ascii" variable Code: if (ascii >= 32 && ascii <= 126) mystr += chr(ascii) ; while (ascii > 0) frame; end end Thanks it worked great! Your way works much better than mine and saves me a lot of sourcecode! [Edited on September 11, 2006 by moi] ____________ |
# |
September 11, 2006, 19:22 | |
Dennis
どこかにいる 2092 posts |
I highly reccommend using ascii because of the thousands of different international keyboard standards.
____________ Kwakkel |
# |
September 11, 2006, 20:12 | |
DTM
Earthling! 821 posts |
Dennis here is your forum. Shoo.
____________ :o |
# |
September 11, 2006, 21:25 | |
Sandman
F3n!x0r 1194 posts |
Moi, are you sure the variable netid is in fact the id of the connection on both sides? You can get it on one side by doing Code: netid = NET_Open(...); On the other side you have Code: if(NET.Incoming[1]==...) // notice the 1 So your netid should be 1. Also, you shouldn't do Code: ballx=NET_RecvVar( netid , &ballx , sizeof(ballx) ); but Code: NET_RecvVar( netid , &ballx , sizeof(ballx) ); because the way you do it, ballx will stay 0 because NET_RecvVar(...) sets it to 0, since 0 is returned when there was no error.
____________ BennuWiki Yes, my avatar has grey borders in IE (so get a decent browser) ROOFLEZ ROOFLEZ |
# |
September 12, 2006, 00:25 | |
moi
Beardless 8 posts |
Quoting Sandman: Moi, are you sure the variable netid is in fact the id of the connection on both sides? You can get it on one side by doing Code: netid = NET_Open(...); On the other side you have Code: if(NET.Incoming[1]==...) // notice the 1 So your netid should be 1. Also, you shouldn't do Code: ballx=NET_RecvVar( netid , &ballx , sizeof(ballx) ); but Code: NET_RecvVar( netid , &ballx , sizeof(ballx) ); because the way you do it, ballx will stay 0 because NET_RecvVar(...) sets it to 0, since 0 is returned when there was no error.Thanks for your reply, Sandman. You are completely right about those. Those "bugs" always come when an unexperienced "programmer" steals code from examples So if I understand correctly, the number which is in NET.Incoming[2] and in NET_RecvVar( 2 , &ballx , sizeof(ballx) ) is the number of connection, which doesnt necesserely has to be stored in a variable so if a client opens a port listening session first it always will have number 1 as connection id and if the client then uses net_open() for sending packets, the number of the new connection automatically becomes 2? Anyway it works now... with a smaller problem: the values of the int variable is received correctly BUT only for some seconds, then it stops and the number keeps staying the same in the console a lot of error messages appear: "Integral size mismatch 4!=16" (sometimes 4!=8)... What does this mean? Are too many packets sent? ____________ |
# |
September 12, 2006, 00:58 | |
Sandman
F3n!x0r 1194 posts |
Quoting moi: What does this mean? Are too many packets sent? Exactly that. The receiver receives an int multiple times and combines them, because it doesn't know better. What you can do is make use of a seperator.Client: Code: NET_Init(0,20,10,0,0,0,0) ; netid = NET_Open("localhost",4555) ; // netid will be 0 because NET.MaxListenPorts = 0 NET_Seperator(netid,chr(13)+chr(10),2) ; loop if(NET.Incoming[netid]==NET_STATUS_ACTIVE) // incoming message NET_RecvVar(netid,&ballx,sizeof(ballx)) ; end end Server: Code: NET_Init(0,20,10,1,4555,0,0) ; // 4555 is the port number loop for(c=1; c<=1; c++) // serve multiple connections (don't use only 'netid' as a var then if(NET.Incoming[c]==NET_STATUS_ESTABLISHED) //connection is being made netid = c; // netid will be 1 because NET.MaxListenPorts = 1 NET_Seperator(netid,chr(13)+chr(10),2) ; end end if(key(_s)) NET_SendRN(netid,ballx) ; // this function can send ints end end Quoting moi: So if I understand correctly, the number which is in NET.Incoming[2] and in NET_RecvVar( 2 , &ballx , sizeof(ballx) ) is the number of connection, which doesnt necesserely has to be stored in a variable so if a client opens a port listening session first it always will have number 1 as connection id and if the client then uses net_open() for sending packets, the number of the new connection automatically becomes 2? Yes, this is possible indeed. Connectionnumbers start at 0 and go up. But beware: 0 - NET.MaxListenPorts are listenconnections NET.MaxListenPorts - NET.MaxConnections are normal connections. You define those variables when you call NET_Init(). I advise you to look in the Notes section and in the Example section of the document. ____________ BennuWiki Yes, my avatar has grey borders in IE (so get a decent browser) ROOFLEZ ROOFLEZ |
# |
September 12, 2006, 16:19 | |
moi
Beardless 8 posts |
Thanks Sandman! I definetely will try your code. As for watching the documentation, I do, I have even printed it out, still there are some problems for me to understand all commands completely, not because it is written badly but because I'm still such a noob. Sometimes even if I understand how a function works, i still don't know where to use it and what for
____________ |
# |
September 12, 2006, 22:57 | |
moi
Beardless 8 posts |
Another important question i have is: It's quite annoying to ask the clients for their ips to be able to send data bach to them. How do I get the ip of the client? I mean, in the console you can always see the hostname of the connected client and there's a function called NET_IPaddress() but it needs an existing connection id which you get using net_open()(which already needs an ip -.-) if i understand correctly. So is it possible to use net_init() in combination with net_ipadress() to get hostnames from clients which are connected to port the server is listening to? ____________ |
# |
September 13, 2006, 01:11 | |
Sandman
F3n!x0r 1194 posts |
Are you perhaps describing NET_Hostname( byte connection ) ..Gets the hostname of the other peer on the specified connection. or NET_Resolve( string IPaddress ) ..Gets the hostname of the IPaddress specified. A hostname can also be specified. ? I don't exactly get that part of the question. It's like you want an IP address of a client, but you don't know who the client is (because you want the IP of a not connected 'client'). Why would you want this anyway? You can use hostnames instead of IPaddresses in functions like NET_Open(). And you can always send data back. When the client opens a connection to a server, the server acknowledges the same connection and puts it in the list as a normalconnection. Then you can just use NET_Send(netid,...) (and others). The only distinction between a 'client' and a 'server' with Network.DLL, is the client uses NET_Open() and the server accepts the connection (automatically). ____________ BennuWiki Yes, my avatar has grey borders in IE (so get a decent browser) ROOFLEZ ROOFLEZ |
# |
September 13, 2006, 17:31 | |
moi
Beardless 8 posts |
Well thats my fault, I should have explained it better. At the moment my test program works this way: -2 EXE, a client and a server() the only difference between them are that they use different ports, run from 2 different pcs(=have different IPs) and that the server first waits for a message from the client before answering to it. The disadvantage from this method is: as server you have to know the ip from the client before you start your server. Of course the client has to know the ip from server as well but this is not unusual This method can be called peer to peer as well i guess... Well what I want to do is to create a real server<>client connection. So the server first doesn't know the ip/hostname from the client. Then after the client has connected the server stores his ip in a variable an connects to it via its port... here is an example of a partial working code: Code: loop //reading the incoming data, my server is listening to port 3435 If (Net.incoming[1]==NET_STATUS_ACTIVE or Net.incoming[1]==NET_STATUS_ESTABLISHED) clientip=NET_IPaddress(1); Message=NET_GetMessage(1); //speichern in message if (message=="ready") clientconnected=1; //here is the problem: clientip= ;// i want to get the ip from the origin of "NET.incoming[1]" somehow end if (clientconnected==1&&connectedtoclient==0) //now using that ip i can conntect to the client using HIS open port 3536: netid=NET_Open(clientip,3536,NET_CONNTYPE_EXTERNAL); connectedtoclient=1; end end I hope this was clearer, I can send you the whole source if you want... ____________ |
# |
September 13, 2006, 21:27 | |
Eckolin
Quite Whiskered 388 posts |
Why wouldn't NET_ipaddress(1); work? (Also I see a German comment there... ) [Edited on September 13, 2006 by Eckolin] ____________ Maker of Games... Wisdom is supreme; therefore get wisdom. Need help with coding? I probably wrote something similar. |
# |
September 13, 2006, 22:13 | |
moi
Beardless 8 posts |
Quoting Eckolin: Why wouldn't NET_ipaddress(1); work? well I've tried:Code: If (Net.incoming[1]==NET_STATUS_ACTIVE or Net.incoming[1]==NET_STATUS_ESTABLISHED) Message=NET_GetMessage(1); //speichern in message if (message=="ready") clientconnected=1; clientip=NET_IPaddress(1 ) ;// i want to get the ip from the origin of "NET.incoming[1]" somehow //here is the problem: clientip=NET_IPaddress(1); //should return the client ip, but doesn't end Ive checked the value of clientip after clientip=NET_IPaddress(1); but it's still =="" Quoting Eckolin: (Also I see a German comment there... ) Hehe I thought I had removed all of them before posting the source... I hope it's not the reason why the program doesn't work ____________ |
# |
September 14, 2006, 01:40 | |
Sandman
F3n!x0r 1194 posts |
What you are describing in the post before your last post is how it should normally work. I don't get why you think the server needs the IP of the client before the connection. The client opens a connection and the server accepts it and automatically has a connection to the client. About clientip: is it a string? Is Message in fact "ready"? In general I see a lot of people not using the example Switch() (in the documentation!) as a basis. That's fine, but it's the best solution I can think of for all functionality. You for example can't handle multiple messages per frame, because you don't have the loop-structure with NET_GetMessage(). So: Quoting moi: Code: if (clientconnected==1&&connectedtoclient==0) //now using that ip i can conntect to the client using HIS open port 3536: netid=NET_Open(clientip,3536,NET_CONNTYPE_EXTERNAL); connectedtoclient=1; end Quoting moi: i want to get the ip from the origin of "NET.incoming[1]" somehow NET.Incoming[] shows the current state of activity, not a message or a peer itself. And as far as I know, NET_IPAddress() works.
____________ BennuWiki Yes, my avatar has grey borders in IE (so get a decent browser) ROOFLEZ ROOFLEZ |
# |
September 15, 2006, 16:24 | |
moi
Beardless 8 posts |
Quoting Sandman: What you are describing in the post before your last post is how it should normally work. I don't get why you think the server needs the IP of the client before the connection. The client opens a connection and the server accepts it and automatically has a connection to the client. Got it to work with your switch()-using example code!About clientip: is it a string? Is Message in fact "ready"? And yes the Message was "ready", maybe I looked dumb in some posts, maybe even dumber than i actually am Quote: You for example can't handle multiple messages per frame, because you don't have the loop-structure with NET_GetMessage(). Actually it WAS in a loop, you can see the more complete source some posts above Well I'll try to get the separator to work now Thanks for your patience ____________ |
# |
September 15, 2006, 17:53 | |
Sandman
F3n!x0r 1194 posts |
Quoting moi: Quote: You for example can't handle multiple messages per frame, because you don't have the loop-structure with NET_GetMessage(). Actually it WAS in a loop, you can see the more complete source some posts above Well I'll try to get the separator to work now Thanks for your patience :D Actually I meant this (repeat-until-)loop: Code: // msg is a string // conn_counter is the connection counter of the for() loop case NET_STATUS_ACTIVE: // ...there's >0 new messages on this connection msg = NET_GetMessage(conn_counter); repeat say("Incoming(" + conn_counter + "): " + msg); msg = NET_GetMessage(conn_counter); until(len(msg)<=0) end And seperators make life easy. ____________ BennuWiki Yes, my avatar has grey borders in IE (so get a decent browser) ROOFLEZ ROOFLEZ |
# |
October 13, 2006, 01:35 | |
link3rn3l
Whiskered 78 posts |
hello sandman you can send us the library source code to compile with CVS version, and include in the next fenix pack? thanks, info_coldev@yahoo.com http://coldev.8m.com ____________ |
# |
Page 1 , 2 , 3 , 4 , 5 , 6 , 7 |
Message Board > Fenix / Bennu / Gemix / DIV > [DLL] Network.DLL