Question

creating a rcon type application in delphi

Asked by: ezpete

Hello Experts,

I am here once again in need of your help, I want to build a remote console (RCON) application that I can use for my gameserver (i realize there are many out there that work just fine but would like to create my own for the experience and customization options) but the problem is I have no idea where to start. All I know is the server uses the UDP protocol and it's a quake3 based gameserver, after that I am kind of lost so I hoping someone here might be able to provide me with some information (pref with examples) on how I can do things like.

Connect to the remote server from my delphi app.
Issue commands to the remote server from my app.
Query the remote server to get information like the players on the server.

I am NOT looking for someone to build me an application. I just need some EASY to follow instructions / examples that I can learn from and apply to do this on my own.

Thanks for all replies in advance,
Pete

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-10-28 at 16:17:51ID24853047
Topics

Internet and Delphi Programming

,

Delphi IDE

,

Delphi Components

,

Delphi Programming

,

Pascal Programming Language

Participating Experts
1
Points
500
Comments
53

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Delphi application to...
    How can I send parameters from a Delphi application to a console or DOS mode application and run this in the background?
  2. udp
    i am trying to make a UDP client\server program. so far i am able to send text to the server but i would like to open the cd rom on the server how can i do this in delphi 3 using UDP where do i put the code on server or client?
  3. Delphi Disadvantages
    What is the Disadvantage Of Delphi against other language?
  4. Delphi + Unix
    How can I launch a shell command on a Unix machine by a delphi code?
  5. Director and Delphi
    Hi, Is there any way to play a director movie (dcr?) in a delphi application? Flash movies are no problem, but I am having great difficulty playing director movies. It seems funny that swf's are supported by delphi but not dcr's? Thanks in advance Philip
  6. Delphi
    I need some help with following . I need to modify the codes for our tracking system application which is written in Delphi. it runs on paradox . how do I modify these codes to be able to run on oracle database. or what other information do I need, since I don't know Delphi

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: MerijnBPosted on 2009-10-28 at 16:29:33ID: 25689317

Do you have any documentation on the protocol used?

 

by: ezpetePosted on 2009-10-28 at 17:01:02ID: 25689461

if you are referring to the quake 3 protocol then I have to admit I really don't know anything about it, however I have found a couple of website that talk about it.

http://www.tilion.org.uk/Games/Quake_3/Network_Protocol
http://www.int64.org/docs/gamestat-protocols/quake3.html

The problem is I have no idea how to interpertate that information (I have never worked with socket programming in my life so I don't know what I am looking at or how to translate it to delphi code).

Thanks,
Pete

 

by: ezpetePosted on 2009-10-28 at 17:07:09ID: 25689480

This site also  talks about it but again I am not sure how to analyze the information I am seeing or what I am supposed to do with it. BTW sorry for the double post but EE won't let me edit my post it seems.

Link: http://www.wireshark.org/docs/dfref/q/quake3.html

 

by: ezpetePosted on 2009-10-28 at 19:26:18ID: 25690170

I have since found a way to do what I need to do not using delphi so please close this question thanks.

 

by: MerijnBPosted on 2009-10-29 at 00:56:49ID: 25691357

A too bad, I had the feeling a nice learning opportunity was growing :)

Out of curiosity, how are you doing this now?

 

by: ezpetePosted on 2009-10-29 at 23:42:48ID: 25700546

still need help afterall

 

by: ezpetePosted on 2009-10-29 at 23:55:25ID: 25700573

It looks like my solution (a web based rcon application) was not living up to what I wanted it to be so I have reopened this question as before.  To update tho I have found out that I would need to use the UDP protocol to accomplish my task and have since downloaded the INDY10 components for Delphi and I am currently looking over some of the documentation but it seems abit over my head at this point so I am still needing alot of help in this area so I can do things like I said before such as.

Connect to the remote server from my app.
Issue commands to the remote server from my app.
Query the remote server to get information like the players on the server.

Again, what I am looking for is not a full program but rather examples (pref using the INDY10 components) that will assist me in achieving my goals.

Thanks again for any and all replies,
Pete

 

by: MerijnBPosted on 2009-10-30 at 00:40:41ID: 25700757

Pete,

I would like to suggest two things:

- Start with a local server, this will make development _much_ easier. If you start with a remote server and things don't work, you don't know what's the cause.
- Don't use Indy. Since it's blocking it's 'extra' difficult to start developing with. I suggest you use ICS: http://www.overbyte.be/frame_index.html?redirTo=/products/ics.html

 

by: ezpetePosted on 2009-10-30 at 04:26:46ID: 25701839

Hello,

I think you are overestimating my experience in this area. I don't even mean what you say blocking (i can guess but I would rather not make a fool of myself) however I did download and installed ICS but now I am more confused than ever on how this thing works. I looked at a couple of the demos that came with it but could not make head or tails of them the only thing I think I have figured out is I am going to be using the WSOKCET component to access the server and do whatever I need to do but it's far more advanced then the INDY version so again I have no idea what half of the properties mean. As far as using a local server goes for testing that seems fine. I can just start one of my games on my local machine and run it in server-mode but to be perfectly hones I am really not sure where I need to start so as I said examples would really come in handy at time like this and I thank you for your time and replies once again.

Cheers,
Ezpet

 

by: MerijnBPosted on 2009-10-30 at 04:51:26ID: 25701971

Don't worry, I'm not overestimating :) I'll (try to) provide you with what you need.
Blocking basically means that you are required to put your stuff in a thread, which makes things extra complicated.

I'll get back soon.

 

by: MerijnBPosted on 2009-10-30 at 14:02:52ID: 25706786

Hi Pete,

I'd like to get some sort of idea at what level your knowledge is atm.
Can you tell me (short) of what parts you think you have an idea how to do it. If you read the docs on the protocol (this one also seems quite good: http://aluigi.altervista.org/papers/q3info.txt). Is it all gibberish or do you understand parts? What kind of (Delphi) apps have you written before?

Don't spend too much time into answering, just give me quick glimps please so I know at what level to start.

 

by: ezpetePosted on 2009-10-30 at 14:37:00ID: 25706975

Thanks for the help, I tried looking through the ICS stuff abit more and on their website they say there is an UDPSend demo app that comes with the component but I could not find it in the version I downloaded V7 so I tried to make my own little demo to get the server status from my game (running on localhost) but I received an error message saying something like Socket is not connected in Send (Error: 10057). Here is what I tried to do.

1.) Created a new app and dropped a WSocket component, A Button and Memo control onto my form
2.)  I set properties for the WSocket control (named WSocket1) as such

Addr: localhost (I also tried 127.0.0.1 but did not make a difference)
Port: 27960 (this is the default port for my game server)
Proto: udp

All other properties were left at the default values.

3.) I then applied the following code to my buttons OnClick event.

procedure TForm1.Button1Click(Sender: TObject);
begin
WSocket1.SendStr('ÿÿÿÿgetstatus');  //this is the string that is needed to be sent to get the status from my server so atleast I figured something out lol.

Memo1.Lines.Text := WSocket1.ReceiveStr();
end;

4.) I started my local game server and then ran my demo app and clicked on the button and it was at that time that I received the error above.

On a side note I ran the same setup using the INDY UDPClient component and the status was displayed in the memo as I expected it to be (albeit unparsed so I don't know what to do about that) but it did work so I don't know what I need to do to get the same result with ICS and still do not know how to do anything other then that at the moment. Anyway I look forward to your replies.

Thanks Again,
Pete

 

by: ezpetePosted on 2009-10-30 at 14:53:16ID: 25707064

Hello again, It looks as if we posted at the same time so I did not see your question before. Well I looked at the page you pointed to and most of it made sense, I did not quite understand the challenge stuff but the rest of it seemed ok. As far as my experience with Delphi I have to admit I am just a hobbyist at best and have never really read any books or had any formal training. I mostly turn to delphi when I cannot find an already existing application that will suit my needs. I then try to find as many examples as I can (and eventually end up here at EE) to help me build the app I need.

Most of the programs I have made are what I call automation type programs which basically automates a task that I could do manually, much in the same way batch files do. I have written a MP3 application using the BASS library and a basic Notes / Reminders type of application which stored information into a Firebird database but that's really about it. I hope that answers your question and thanks again.

Pete

 

by: MerijnBPosted on 2009-10-31 at 09:08:00ID: 25710262

Hi ezpete. Reading about what you did before and how you try now I think this won't be too hard, you're guesses are quite into the right direction.
The documentation on the protocol is sometimes somewhat contradicting, so you'll have to experiment somewhat.

The error above is because of the following reason: to receive data, you'll not a server, not a client. I think it's named TWSocketServer.
Set the port, set the protocol to UDP and I think there is a property Active which you need to set to true (otherwise call Listen() when your application is starting up).
It has some events, use those to see if you receive data. Let me know how you go :)

 

by: ezpetePosted on 2009-10-31 at 19:38:07ID: 25712418

Hello again MerjinB,

I did as you said and recieved another error message about the port already being in use which makes sense because we using the method you described above makes it so there are 2 servers (my local game server & the test app server) both run on the same port so I don't see how that will work, if I omit the listen(); function the above error goes away but then I am given the same 100057 send error as before so it looks like that's not going to work either. Also I am abit concerned about running a server like that on my machine and even more so if I share the application with other because then anybody would be able to connect to their computer on that port if they do not have a firewall properly configured and possibly use it to gain access to their computer so I really don't feel comfortable doing it like that. Anyway, despite the problems with the INDY components that you described, t I am really leaning towards them because they seem to work so far and are a lot less confusing aswell however if anyone can show me a working example with ICS then I will try to chug along with it instead.

Cheers,
Ezpete

 

by: MerijnBPosted on 2009-11-01 at 05:53:23ID: 25713695

Hi Pete,

You are right about running 2 servers with the same port. Looking at the docs, it seems that you can choose any port you like to receive the data on, so I suggest you set _your_ udp server to 1 port above the Q3 server's (27961).

If you omit the call to Listen(), the UDP server never starts, so that's the reason you won't get an error.

Please keep in mind that you can't call ReceiveStr() on the socket you sent data with. Since UDP is 'connectionless' you'll need to get the data via your UDP server, and send it via the UDP client.

I don't think there is a reason to worry about running but the gameserver and your app on the same machine, that's something look at when the communcation and data parsing itself is working, one step at a time.

You are ofcourse free to use Indy if you like it better, it's just a different way of using the TCP stack. It doesn't really matter which one you use to make what you want, though I still think for now ICS will make it easier for your to parse the data you receive back.

Can you tell me what game it is you are testing with?

On the header (ÿÿÿÿ): It's very posible that this is wrong, the documentation states it should be 4 bytes of $FF, this might be represented as ÿÿÿÿ, but it can be wrong just as easy. See code example below how to create to proper header.

Another tip: it might be hard to get a proper response from your game at first, so if you send stuff, but you don't receive anything back, first send data to yourself. Setup your UDP server, let your client point to localhost or 127.0.0.1 using the port of your own server (not the game's). Then you should receive the data you sent yourself.

Happy coding...

unit Unit2; 
interface 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls; 
const HEADER = #$FF#$FF#$FF#$FF; 
type
  TForm2 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end; 
var
  Form2: TForm2; 
implementation 
{$R *.dfm} 
procedure TForm2.Button1Click(Sender: TObject);
begin
 WSocket1.SendStr(HEADER + 'getstatus');
end; 
end.
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:

Select allOpen in new window

 

by: ezpetePosted on 2009-11-02 at 12:53:55ID: 25723589

Hello Again,

Thank you for all of your help again I have successfully created the application using the INDY components but you seem very convinced that this is not the way to go so I will continue to try and use the ICS components and see how it goes. I will add the CONST as suggested and get back to you on the results.

Thanks Again,
Ezpete

 

by: MerijnBPosted on 2009-11-02 at 13:38:04ID: 25724030

If it works with Indy that's ok, it will work both ways. If you're comfortable using Indy stick to it.

What have you managed to get working, what do you need help on now?

 

by: ezpetePosted on 2009-11-03 at 05:08:15ID: 25728514

I pretty much got it working but when I issue a serverinfo command via rcon it only returns part of the infomation and I have to submit the same query 3 or 4 more times to get all the information. I assumed this was because I had the buffer set to low but I doubled it from 8192 to 16384 but that did not make a difference so if you have any suggestions to fix that then it looks like I might be ok.

Thanks,
EzPete

 

by: ezpetePosted on 2009-11-03 at 05:20:11ID: 25728606

Also it appears if I issue a command and then issue another command right after it then it will just reply the last command twice. This may be that blocking stuff you were talking about I do not know. Again any help would be appreciated.

Thanks Again
EzPete

 

by: MerijnBPosted on 2009-11-03 at 05:23:15ID: 25728625

Are you sure you don't receive all information?

It's possible that you receive information back in blocks, not all at once.

 

by: ezpetePosted on 2009-11-03 at 16:24:09ID: 25735346

I don't really know but I have been doing some reading and it appears I might have to concatenate the packets and show them all at once but I have no idea how to do this at the moment. I am going to try the ICS components one more time and see if they work any differently. This is is turning out to be more then I really expected I just hope I have something to show for it in the end.

Cheers,
EzPete

 

by: ezpetePosted on 2009-11-03 at 17:26:09ID: 25735643

Ok this is just getting more and more frustrating as it goes. I have tried messing with the ICS components as suggested and it seems nothing I do works. I keep getting the 100057 error message (socket is not connected in Send) I will try to provide as much information as I can to show you what I am doing and maybe you can see where I am going wrong with this as I said examples would be greatly appreciated.

Anyway this is what I tried to do with ICS..

1.) Created a new app
2.) Put a richedit, a button, and  the Wsocket and WsocketServer controls on the form.
3.) I then set the properties for the Wsocket control as such.

 Addr: 127.0.0.1
 Port: 27960
 Proto: udp

4.) I then set the properties for the WSocketServer control as such.

 Addr: 127.0.0.1
 Port: 27961
 Proto: udp

5.) I then set the my unit with the code as attached.



6.) I then started my local gameserver and started my app

7.) I then clicked on button1 to send the serverstatus command to the server and again received the error mentioned above.

I guess I don't understand as much as I thought I did and will need alot more help then originally thought so as I said before examples would help immensely and thanks for your time again.

Ezpete

unit Unit1; 
interface 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, OverbyteIcsWndControl, OverbyteIcsWSocket,
  OverbyteIcsWSocketS;
  const HEADER = #$FF#$FF#$FF#$FF;
type
  TForm1 = class(TForm)
    WSocket1: TWSocket;
    RichEdit1: TRichEdit;
    Button1: TButton;
    WSocketServer1: TWSocketServer;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end; 
var
  Form1: TForm1; 
implementation 
{$R *.dfm} 
procedure TForm1.FormCreate(Sender: TObject);
begin
 WSocketServer1.Listen();
end; 
procedure TForm1.Button1Click(Sender: TObject);
begin
 WSocket1.SendStr(HEADER + 'getstatus');
 WSocketServer1.ReceiveStr();
end; 
 
end.

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:

Select allOpen in new window

 

by: MerijnBPosted on 2009-11-03 at 22:54:47ID: 25737014

Changing to ICS probably won't help you with how you receive the data (if you need to concatenate or not), so for now just stick to Indy since you already got that working,

Can you show the Indy code you have working? Can you give me the link where you read you need to concatenate?

Normally (with a good designed protocol) the end of the data is always marked with a special character. In this case, you can simply search the data for that character so you know you have all the data. I haven't something like this in the Q3 protocol, so this might be a little harder.

 

by: ezpetePosted on 2009-11-04 at 02:47:45ID: 25738021

Here is the code I used  for the INDY Components.

Pretty much the same setup except I did not need a UDP server component as the client seemed to handle everything on it's own. As far as source for the concatenation of the packets, there is no definitive source however I know of at least one other program out there (rcon unlimited) which returns the FULL details for serverinfo so I am assuming that is how they did it but could be wrong. The problem I am having with the INDY code I am using is that it seems to be that if the full result is not returned I have to press the send button multiple times to get all the information I asked for and then if I try to change the command to another command the program runs the last command the amount of times it took me to get all the information which messes everything up. I know my description is vague at best so I will give you an example to help clear things up.

Suppose I issue a STATUS command to my server, what should happen is I am given text based grid with information about each player on my server (things like name, ping, guid, etc..)  but what happens instead is I am only receive the information for a few players and I have to submit the command again and again and each time I do this I am given another part of the list but never the full list. This goes on until I reach the end of the players list. Now say for example I had to press the send button 3 times to get all the players information and then I want to issue another command (dumpuser 2 for example) what should happen is I should get more detailed information about player 2 but what happens instead is the status info shows up again until I press the button 3 more times and THEN I am given the information for player 2 and this whole cycle repeats for every other command I issue until I close down my application and start it over it over again and I can only assume the reason it is doing this is because ALL the information should have been returned in one go but it wasn't for some reason so something gets stuck someplace and the only way to fix it is to restart my app and try again until I issue another command that gets stuck if that makes any sense to you at all because it doesn't for me.

Anyway you can see my code and it very well may be something I am doing wrong or I am sending the information in the wrong way or asking for it to be returned in the wrong way I don't know. All I do know is it's really frustrating because I know from the (rcon unlimited) program that this information should be returned in one big chunk and not split up like it's doing with my app. Anyway hope this helps explain the situation and you can see what I am doing wrong and thanks yet again for your time and help.

Cheers,
EzPete

unit Unit1; 
interface 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdUDPBase, IdUDPClient,
  IdAntiFreezeBase, IdAntiFreeze, ComCtrls; 
type
  TForm1 = class(TForm)
    UDPClient: TIdUDPClient;
    Button1: TButton;
    Edit1: TEdit;
    Button2: TButton;
    Label1: TLabel;
    Edit2: TEdit;
    Label2: TLabel;
    Edit3: TEdit;
    Label3: TLabel;
    IdAntiFreeze1: TIdAntiFreeze;
    UDPRichEdit: TRichEdit;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end; 
var
  Form1: TForm1; 
implementation 
CONST
HEADER = #$FF#$FF#$FF#$FF;
RECIEVETIMEOUT = 5000; // milliseconds 
{$R *.dfm} 
procedure TForm1.FormCreate(Sender: TObject);
begin
  UDPClient.ReceiveTimeout := RECIEVETIMEOUT
end; 
procedure TForm1.Button1Click(Sender: TObject);
var
 ReceivedString: String;
begin
  UDPClient.Send(edit2.Text,27960, HEADER + 'getstatus');
  ReceivedString := UDPClient.ReceiveString();
  If ReceivedString = '' then
    UDPRichEdit.Lines.Add('No response received from the server after ' + IntToStr(UDPClient.ReceiveTimeout) + ' millseconds.' + #13#10 + 'Make sure the IP address is correct and the server is running and port ' + IntToStr(UDPClient.Port) + ' is open.')
  Else
    UDPRichEdit.Lines.Add(ReceivedString);
end; 
procedure TForm1.Button2Click(Sender: TObject);
var
 ReceivedString: String;
begin
  UDPClient.Send(edit2.Text,27960, HEADER + 'rcon' + ' ' + edit3.Text + ' ' + edit1.Text);
  ReceivedString := UDPClient.ReceiveString();
  If ReceivedString = '' then
    UDPRichEdit.Lines.Text := ('No response received from the server after ' + IntToStr(UDPClient.ReceiveTimeout) + ' millseconds.')
  Else
    UDPRichEdit.Lines.Text := (ReceivedString);
end; 
end.

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:

Select allOpen in new window

 

by: ezpetePosted on 2009-11-04 at 06:04:49ID: 25739369

Hello Again,

I did some searching for the problem I was having and found this page. http://www.splashdamage.com/forums/showthread.php?t=18600 and the guy there was having much the same problem I am having and the solution he used was to use a loop. Here is a quote from the person who helped them.

"The response from an RCON command has a maximum packet size of about ~288bytes. If the response is larger than this then the message is truncated and continues being sent in a new packet."

So I guess my question now is how would I add the loop so it will return all the information I need. If you can help me with this then that would be great.

Thanks,
Ezpete

 

by: ezpetePosted on 2009-11-06 at 16:27:06ID: 25764314

Hello Again,

I found a piece of php code which I think will work to solve my problem with the packets not being sent back in one go but it's in php code which I do not know so if anyone here knows how to port this function over to delphi code then I think it will finally solve all my problems and I thank you again in advance for any and all replies..

function rcon ($ip, $port, $rcon_pass, $command) {
	$fp = fsockopen("udp://$ip",$port, $errno, $errstr, 2);
	socket_set_timeout($fp,2); 
	if (!$fp)	{
		echo "$errstr ($errno)<br>\n";
	} else {
		$query = "\xFF\xFF\xFF\xFFrcon \"" . $rcon_pass . "\" " . $command;
		fwrite($fp,$query);
	}
	$data = '';
	while ($d = fread ($fp, 10000)) {
	    $data .= $d;
	}
	fclose ($fp);
	$data = preg_replace ("/....print\n/", "", $data);
	$data = stripcolors ($data);
	return $data;
}
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:

Select allOpen in new window

 

by: ezpetePosted on 2009-11-07 at 18:15:15ID: 25769120

Thanks I hope it helps.

 

by: MerijnBPosted on 2009-11-08 at 12:43:23ID: 25771785

Hi Pete,

Some of the things you describe don't seem to make sense. Can you tell which game you are running or do you have a server I can do some tests against?

 

by: ezpetePosted on 2009-11-08 at 22:21:21ID: 25773708

Hello again and I am not sure what doesn't make sense so if you could clarify what you mean then I might be able to answer any questions you might have. I do have a few game servers but unfortunately you would not be able to get much information from them unless you had the rcon password which I am sure you can understand I will be unable to provide. I can however tell you the game that I trying this with. It's a quake3 arena based game called Urban Terror. I have have been to their forums to ask the same question I am asking here but that turned out to be an exercise in futility.

Anyway in the hopes it will provide useful, I have provided a complete UDP stream dump (from wireshark)  from one of my servers after issuing a rcon command named CVARLIST which returns every variable the server has. In this case the information was returned in 12 packets which all start with the same text,  ÿÿÿÿprint  this is followed by the actual variables and their values.

The one thing that the information does not show is any special characters at the end of the last packet which is received (like a delimiter or something like that) which would help to identify it as the last packet.

Also, I changed all sensitive information in the file (passswords and ip addresses) with asterisks and 0's just in case you were wondering why they were there. Anyway that's about all I know at this point and as I said I hope seeing how the information is returned helps and once again I thank you for you time.

Ezpete

 

by: MerijnBPosted on 2009-11-09 at 04:38:58ID: 25775317

rcon pass is also needed for getstatus? If so, how are ppl going to find your server?

 

by: ezpetePosted on 2009-11-09 at 09:43:42ID: 25778156

no rcon password is not needed for that. you can test that on this server if you like. 208.43.15.81:27960 that is one of our game servers.

 

by: ezpetePosted on 2009-11-09 at 09:45:27ID: 25778176

the reason I did not mention getstatus is because it is sent differently then the other commands. It arrives as 1 packet in it's complete form so I am not sure how helpful it will be if you issued that command but it's worth a shot I suppose.

Thanks Again,
ExPete

 

by: MerijnBPosted on 2009-11-09 at 10:14:25ID: 25778449

> It arrives as 1 packet in it's complete form so I am not sure how helpful it will be if you issued that command

Ok, I didn't know that, that indeed was my idea, to try with that.

Is there a test server you can temporary change the rcon password of you can sent me to test?

 

by: MerijnBPosted on 2009-11-09 at 10:16:33ID: 25778477

And on another note, are you familiar with HLSW?

 

by: ezpetePosted on 2009-11-10 at 00:50:57ID: 25783481

Unfortunately, all of our servers  are live servers which I could not change the password for however the game is free so you could always grab a copy and test on a local server and I do know what HLSW is why do you ask ?

EzPete

 

by: MerijnBPosted on 2009-11-10 at 01:04:31ID: 25783547

I'll install a local server, though it might be hard to make it send a (too) long udp message if there is nobody playing.

 

by: ezpetePosted on 2009-11-11 at 00:11:31ID: 25793088

the biggest command that sends the biggest results is "cvarlist". it will send the biggest udp message back over all other commands. If you can get that one working then the others would be a breeze.

 

by: MerijnBPosted on 2009-11-11 at 14:20:13ID: 25799763

I've installed a server and will take a shot at it soon.

 

by: ezpetePosted on 2009-11-11 at 20:59:14ID: 25801641

Thanks, this problem has been plaguing me for a week now and it's the only thing that is holding up my application. I to will keep looking for an answer of course but as you know the documentation is pretty much non existent so I am not sure I will find anything new. Thanks again.

Ezpete

 

by: ezpetePosted on 2009-11-18 at 10:01:42ID: 25852776

So no news yet  ... If you need assistance getting the server you downloaded to run I can help you there I just need this issue resoloved asap.

Thanks,
Ezpete.

 

by: MerijnBPosted on 2009-11-18 at 11:04:51ID: 25853497

Hi Pete,

I have the server running, just a little busy with work. I'm planning on taking a look later tonight or tomorrow. Keep you posted.

 

by: ezpetePosted on 2009-11-19 at 10:56:58ID: 25863627

No problem thanks again for your time I really appreciate it.

 

by: MerijnBPosted on 2009-11-20 at 07:06:23ID: 25870976

Hi Pete,

Sorry for the delay, I've been a little ill yesterday. I've made a little rcon app running against my local urban terror server (nice game btw).

It seems the server indeed sends the resulting data in packets, but it does sent them all automatically. It seems you can recognize the last packet because it starts with an LF ($0A). I've attached my (at least here) working app. I've build it with ICS, but you can adopt this to Indy if you wish.

Let me know how you go!

EE is giving me a hard time attaching the file. It's a tar archive, not a jpg. Just remove '.jpg' from the filename.

 

by: ezpetePosted on 2009-11-20 at 23:29:54ID: 25876895

Thanks,

I will test it out over the weekend and let you know how it goes.

Ezpete

 

by: ezpetePosted on 2009-11-25 at 03:11:34ID: 25905955

Hello Again,

I tested your program and it seems like it's hit n miss depending on the server the command is issued on. Also, as you said you used ICS which has an OnDataAvailable method which Indy does not and I am not sure there is a comparable way of doing this will INDY so I have no way of testing it with INDY. Lastly, I would use ICS but it gives me all kinds of errors when trying to connect to a server (even your little app errors out if you issue the cvarlist command more then once before closing the app) so ICS is not a option for me i'm afraid so if you could explain what I would need to do to make this work in INDY then I guess I will have all the info I need.

Thanks Again,
Ezpete.

 

by: MerijnBPosted on 2009-12-02 at 00:52:33ID: 25950191

Sorry for the late reply, I missed yours :x

For Indy it should be something like the following snippet.
I haven't tested it, but I think it gives you a good starting point.

const HEADER = #$FF#$FF#$FF#$FF;
      LF = #$0A;
      CR = #$0D; 

procedure TForm1.Button1Click(Sender: TObject);
var
 ReceivedString: String;
 RxBuffer: String;
begin
  UDPClient.Send(edit2.Text,27960, HEADER + 'getstatus'); 
  RxBuffer := '';
  ReceivedString := 'dummy';
  while ReceivedString <> '' do
  begin
    ReceivedString := UDPClient.ReceiveString();
    RxBuffer := RxBuffer + ReceivedString;
  end;   
  If RxBuffer = '' then
    UDPRichEdit.Lines.Add('No response received from the server after ' + IntToStr(UDPClient.ReceiveTimeout) + ' millseconds.' + #13#10 + 'Make sure the IP address is correct and the server is running and port ' + IntToStr(UDPClient.Port) + ' is open.')
  Else
    if fRxBuffer[Length(fRxBuffer)] <> #$0A then
      UDPRichEdit.Lines.Add('No valid response received from the server after ' + IntToStr(UDPClient.ReceiveTimeout) + ' millseconds.' + #13#10 + 'Make sure the IP address is correct and the server is running and port ' + IntToStr(UDPClient.Port) + ' is open.')
    Else
      // replace LF with CR + LF to make it more readable in the TMemo
      MemoResponse.Text := StringReplace(RxBuffer, LF, CR + LF, [rfReplaceAll]);
end;

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:

Select allOpen in new window

 

by: ezpetePosted on 2009-12-07 at 02:15:00ID: 25987576

Thanks for the reply I will take a look at it and let you know how it goes. Hopefully this will be the end of it.

Thanks,
Ezpete

 

by: ezpetePosted on 2009-12-07 at 22:30:17ID: 25995429

Hello again,

It seems you finally got it. Tested it on a few servers and using INDY I do not get funny results the way I did with ICS thank you very much for sticking with me on this now I can finally move on to finishing this beast :)

Cheers,
EzPete

 

by: ezpetePosted on 2009-12-07 at 22:30:52ID: 31647271

Thank you very much for your help and time.

 

by: MerijnBPosted on 2009-12-07 at 22:41:10ID: 25995472

You're welcome and good to hear it worked out.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...