Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

winsock udp & sending multiple commands

Status
Not open for further replies.

DrAlbany

Programmer
Jun 14, 2003
46
GB
Hi Guys..,

Hope someone can help..

I am writing an "rcon" - "remote control" for COD4 (call of duty 4) game.

I have it working and receive data no problem when sending one command at a time.

so, the user clicks "connect" and the "sv_hostname" command is sent, the responce is...

------------
"sv_hostname" is: "Alien Containment Squad^7" default: "CoD4Host^7"
Domain is any text
-----------

I parse the text and get the hostname and place it on screen.

I also have setup timers where every x seconds (15 in my case) the rcon sends the "status" command to the game server and gets back a list of players with their score, so I parse the text file and add the player to a table and displayed on screen.

I can also send a message to player, kick players change to next map etc....

all works fine.

Now i want to get the rcon on connecting to issue multiple requests for informaiton...

e.g.

get sv_hostname - what is the server called
get g_gametype - gets the current game type

plus others....

but, the first command does not work... I have put this down to the command being sent too quickly and being ignored by the server, or similar.

I have tried to put a for..next loop in to add a delay before the next command is sent, even put a wait timeout 1 but still doesn't work.

I've also added a "commandInProcess" type property to .T. and a do..while loop... the property gets cleared to .F. from the getdata of the winsock object...
then the loop exits and the next command is sent.

I hope this makes sense....

It seems as if the commands are sent too quickly for winsock to action them, so it does the last one...

any ideas of how i can slow the commands down, but still let the winsock do what it needs to do.

Hope soemone can help.


Regards

Steve


only way i can think of is a command cue with a timer...hmmmm...


any help would be appreciated

Regards

Steve

Watch ya back, because some times the devil drives a minibus.
 
All I can point you to is the difference of UDP vs. TCP:
As you see UDP is not guaranteeing anything. I also don't know about any specifics of the "call of duty 4" game. Maybe it's so, that you need to wait for the answer of a command you issue, before it's allowed to send the next command, or you'll only get the answer to the last request. Such things are not determined by UDP at all, if you have a reference of the games commands and answers of such a server, maybe you'll find some rules on that.

What's true anyway is, that you need to find out yourself, which answer packages are for which command sent, because answer packages can arrive in any order, you might get the answer to the second command before the first one, etc.

There's no general way to fix your problem without knowing further details about the game's protocol.

Bye, Olaf.
 
Hi Olaf..,

Thanks for your insight... Something else to think about :)

The server is udp not tcp, so out of luck their.

I have the receive que populated with all incoming data, and clearing the buffer once I have taken the info out...

I have a linux box with the game server on as well... looks like I will just keep experimenting.

Thanks for you time.

Regards


Steve



Watch ya back, because some times the devil drives a minibus.
 
One question, if you don't mind: I seldom come across such questions here or elsewhere in Foxpro forums or newsgroups. There seem to be very few, rather equal to noen VFP hobbyist users. As you do this for a game, are you really using VFP for this, or did you just post to any developer forum at all?

Bye, Olaf.
 
I am an IT professional who has been using foxpro since the DOS days, I have used Foxpro for various activites and professional programes over the years.

This is the only place I have posted the question. I frequent the forum on a semi regular basis, but tend not to post a great deal due to other people having more experience, or so it would seems.

I writen multitude of programes from a recruitment program for a large recruitment company in the uk, to our own repair and stock taking program in my computer shop, and a news reader NNTP program, a manufacturing MRP system to enhance a program called MICROSS just to name a few.

I tend to use foxpro for most data manipulation applications as I haven't found much I can't do with foxpro... its such an excellent programming language.

While being old... 43 (just!!! <grin>) I do like playing COD4, and want a way to be able to administer my COD4 server. The applications already available do not have the features I want, my features make it easy to drop out of the game and send a player a message who is taking advantage of the game, and kick the player if needed, keep a log of players and if I have kicked them, or banned them, if they have changed their name to mask their previous activities ...etc...

So, while I have this up and running I wanted to know if others have used the UDP protocol, and had problems with sending / receiving messages due to te unpredicatable and non guaranteed delivery of DUP packets.

I have a very good understanding of tcp/ip and UDP and data manipulation, but never tried using UDP in a program before, so woundered if anyone had any ideas.



Regards


Steve

Watch ya back, because some times the devil drives a minibus.
 
You're welcome , DrAlbany, even if you weren't a professional VFP user. I'm about your age too, I seldom play, but I welcome any unusal use of VFP.

I'm programming VFP not as long as you, started back in 1999 with VFP6. The company I work for does many applications in the sector of research and development of cosmetical products for Beiersdorf.

I've done little with Winsock, but I'm familar on how to use it with TCP/IP and UPD protocol. I never sent requests to a game server though.

I recently do a twitter client and have done a facade to the twitter API without using such a low level class as winsock, I used the XML2.XMLHttp COM class to make requests to twitter.com and evaluate the responses. That may not be applicable with the COD4 server.

Here's a download using VFP, Winsock, UDP for a small chat sample:
It works for me, if unzipped to two different folders (it's createing a table and using it exclusive, therefore two copies) and then changing the Listening Port in one of the copies. Starting each form in a seperate Foxpro IDE session I get a chat...

If that works for you, the rest of the problems should be COD4 related.

Bye, Olaf.
 
Thanks again for your input.

The program works fine when only one command is sent every few seconds.

I can send for example.. multiple text messages to the server, they will all be received and displayed in game.

I get the feeling my commands are being sent too fast for winsock to action them... its weird to expalin...

Its as thought winsock is getting interrupted with the second commmand before its got around to sending the first command.

Its how to best implememt a command que... I think I will experiment with a timer and an array...

similar to this..


add command to que

Send loop
stop send timer
start timeout time
if command que is empty reset timer - start loop again

send next command

if timeout timer reaches zero send message - timeout...

if data received stop timeout timer
deal with data
restart send timer - loops back to begining



Was hoping for an easier solution <Grin>

Logic seems to suggest it *should* work :)

Thanks again...

Sometimes just trying to explain a problem to someone helps create a solution :)

Regards

Steve



If you alway do what you've always done, you always get what you've always got.
 
Well, I hardly can tell if winsock will overtake it's own communication without seeing any code, but if sending such a command is rather atomic I can't imagine what would cause such behaviour. Someting like an overflowing output buffer?
How about summing the length of all sent data, and see if it always happens after a certain number of bytes? Does it happen, when you send and receive at the same time? Do you use the same instance of a winsock control to send and receive?

You may also try another winsock control, for example you find some VFP examples on the Socketwrench control:
Bye, Olaf.
 
Try something like this in SendComplete:

Code:
This.Close()
This.Listen()

Bye, Olaf.
 
The "Setremote" procedure addresses the Multiple Sends problem....

Good luck
 
Thanks for all your input once again....

I'm away fro the weekend (first weekend off in 4 years) YEAH!!! so won't be working on it, but will have a play Sunday night when I get back.

I will post some example code as well.

Many thanks


Steve



If you alway do what you've always done, you always get what you've always got.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top