Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / DarkNet sending old packets?

Author
Message
Interplanetary Funk
14
Years of Service
User Offline
Joined: 19th Apr 2010
Location: Ipswich, United Kingdom
Posted: 22nd Apr 2010 23:32
I'm having a problem with DarkNet, I've written this simple LAN messenger but when I run it, it will only show the first thing i entered, just the user name, or nothing, it also crashes when i run the release build. any help would be greatly appreciated.
(heres my source btw)


this is probably down to my poor coding and lack of experience with networking and DarkNet/DarkGDK, but I would very much like to fix it so I can continue my hopes of programming =) (especially game programming =D)
Interplanetary Funk
14
Years of Service
User Offline
Joined: 19th Apr 2010
Location: Ipswich, United Kingdom
Posted: 23rd Apr 2010 03:50
Also, another question about DarkNet which I cant figure out, I want to enumerate the number of clients connected and then loop through them receiving the packets being sent, any ideas on how I would do this??
Cuddle Bunniezzz 12
15
Years of Service
User Offline
Joined: 14th Jan 2009
Location: Buffalo, NY
Posted: 23rd Apr 2010 04:21
I'd suggest creating a Server version of this and a client version of this.

Have the clients send their messages to the Server, and when a new message is received from one client, send it to the other client.

In this case that you have above, are both users of the chat program servers?

http://www.darkgdk.us/ <- You can now submit pages, upload images, yet were lacking content. We need your help!
Interplanetary Funk
14
Years of Service
User Offline
Joined: 19th Apr 2010
Location: Ipswich, United Kingdom
Posted: 23rd Apr 2010 04:27
Well in the one above, I'm literally just sending packets to everyone and receiving them from everyone, I have already started to rewrite it with a server and client program, though I would like the client to auto find the server on the LAN, which would still need broadcasting for I think (correct me if I'm wrong though). Also, I thought it would be nice for the user to simply be able to use one program for the server and client rather than needing both. But I'll obviously get that done when I manage to figure out how to program effectively with DarkNet.
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 23rd Apr 2010 12:26
Your problem is here:


You should learn how to use C strings and pointers before using them. You are copying into an unallocated pointer, which is criminal!

mnGetStringC returns a newly allocated string so you need to deallocate it with delete[]. Also if(RecieveNew==1) should be if(ReceiveNew>0). You should avoid using broadcasting for anything other than server finding as it has a big overhead on network performance.

Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 23rd Apr 2010 12:42
i believe
char* str;
should be
char* str = new char[256];
over there, as it's pointing to nothing at the moment so you will get an unhandled exception, 256 can be any number, depends on what you need

Interplanetary Funk
14
Years of Service
User Offline
Joined: 19th Apr 2010
Location: Ipswich, United Kingdom
Posted: 23rd Apr 2010 23:07
Okidoke, thank you, I now have:


however, when trying to receive UDP files when acting as a server, i get an error message from DarkNet telling me that there is an invalid client ID. The documentation clearly states that when UDP mode is set to UM_CATCH_ALL that the client id is ignored and can be set to anything. This is a problem as I want to get data from ALL clients and forward it straight away to the rest, and I thought this would be much easier than creating a client struct and looping through it to send data, but that doesn't seem to be the case.

(Sreenshot of error attached)

when I click no to do I want to exit, I receive the exact same error when I try to close the program.

any help??

(sorry to be such a pest, but I am new to this whole networking thing and have only really been programming C++ for about a month or 2)

Attachments

Login to view attachments
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 24th Apr 2010 22:00
In server state you need to set the clientID to the ID of the client you want to receive from.
Quote: "In client state UDP modes UM_CATCH_ALL and UM_CATCH_ALL_NO this parameter should be ignored and can be set to anything."


Interplanetary Funk
14
Years of Service
User Offline
Joined: 19th Apr 2010
Location: Ipswich, United Kingdom
Posted: 24th Apr 2010 22:18 Edited at: 24th Apr 2010 22:40
Ah, okay, sorry, my bad , is there anyway easy way to loop through all connected clients and receive messages or will I have to create a struct that stores the information in an array or something??

Edit:
I've now written this:

though now when I try to close it, it just freezes, its responding, but I can't close it, also, if I try to close it before the "if(IsNotHost)" it still goes into the if statement. Sorry to be such a nuisance.

Login to post a reply

Server time is: 2024-11-20 01:24:39
Your offset time is: 2024-11-20 01:24:39