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.

DLL Talk / Need Help with DarkNet (Chat Program)

Author
Message
DarkJohn20
10
Years of Service
User Offline
Joined: 11th Apr 2009
Location:
Posted: 22nd Aug 2009 06:56 Edited at: 22nd Aug 2009 07:07
Hi, I wanted to make a chat program using DBP and DarkNet, so I started looking at the documentation and writing one.

Here is my code:

Server:


Client:


When I try running the Server, then connecting with the client, everything seems to work, but when I input a name to use, I get the following error:

Error whilst error reporting, could not allocate memory to store error message!

Am I doing something wrong with packet size? or is there something else I am missing?

Any help would be appreciated, not just on this problem, but on any others that you see!

Thanks.

Edit::
Well apparently I cannot code when I have a headache and it is Midnight, because it looks as though I have forgotten to send packets that the server receives to the clients. I do not believe this would fix the error I am getting, but if it does please share!
Michael P
13
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 26th Aug 2009 12:32
You are not using mnAddString properly which is forcing DarkNet to read from memory that it shouldn't. You are sending the packet even when data has not been added to it and you are sending it via UDP in UDP mode 'per client, per operation' without formatting the packet properly.

You shouldn't use UDP to send packets where its essential that they arrive, you should use TCP instead. I've corrected your code which works for me.

Client


Server


You should take a look at the documentation and demo code. These were improved recently and you can download the latest version of DarkNet (1.1.6) from your order history .

DarkJohn20
10
Years of Service
User Offline
Joined: 11th Apr 2009
Location:
Posted: 29th Aug 2009 22:40 Edited at: 29th Aug 2009 22:54
Thank you Michael. I pretty much made what I had by following the examples. One question though. When I type a message, it is displayed to the server, but not to any of the clients, including the one that sent the message. What would I have to do to fix this?

Edit::
Oh, perhaps it has to do with not sending the message to all clients, huh... Silly me, I fixed it, but then I tried your code and forgot to add it back in there. Will try now!
Michael P
13
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 29th Aug 2009 22:51
Using the standard client/server model clients can't communicate directly with each other; everything is relayed by the server. The demos included with DarkNet demonstrate how this is done.

DarkJohn20
10
Years of Service
User Offline
Joined: 11th Apr 2009
Location:
Posted: 29th Aug 2009 23:16
One other thing, is there a different way to accept input?, because I noticed that while awaiting input, nothing else can happen (ex. recieving messages) I noticed that If I type something and press enter a couple times really fast, the message I sent shows up, but otherwise it doesn't.
Michael P
13
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 29th Aug 2009 23:31
entry$ returns what is in the user entry buffer without blocking the execution of your program.

DarkJohn20
10
Years of Service
User Offline
Joined: 11th Apr 2009
Location:
Posted: 30th Aug 2009 03:45 Edited at: 30th Aug 2009 06:02
Michael, I am having trouble with the following:


Also, How would I get the entry to show without clearing and without showing over and over?

And I noticed that I could not connect to my external IP, but only my local one. How would I connect externally (or anyone else for that matter)

Edit::
I added you on MSN if you think that would be easier. My goal isn't for you to do this for me, I would rather learn it. It is just to hard to learn it over forums.

Edit2::
Man, I really wish XGui worked well with Vista, would make chat so much more simple.
Michael P
13
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 30th Aug 2009 13:28
Quote: "How would I get the entry to show without clearing and without showing over and over?"

You clear the screen every loop using CLS and update the display.

Quote: "And I noticed that I could not connect to my external IP, but only my local one. How would I connect externally (or anyone else for that matter)"

From within your LAN clients should use the local IP to connect to the server. From outside your LAN clients should use your external IP; you may need to setup port forwarding.

Quote: "I added you on MSN if you think that would be easier. My goal isn't for you to do this for me, I would rather learn it. It is just to hard to learn it over forums."

Yes, feel free to message me

Login to post a reply

Server time is: 2019-10-16 23:11:47
Your offset time is: 2019-10-16 23:11:47