Community Forums Today's Posts     Member List     Archive    
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2005
    Location
    ABQ, NM
    Posts
    3

    Any advice for C++?

    I've written an app in C++ with MFC that queries my clans CoD server and gets player info. Now I want it to do the same for our TS server.

    I've seen lots of PHP scripts that do this, but when I try to do the same with CSockets I get nowhere. Of course, I don't do PHP and some of the things I see are quite mysterious to me.

    Anyone have any advice for a C programmer?

  2. #2
    Join Date
    Jan 2004
    Location
    Germany
    Posts
    27
    Hmm use "sys/socket.h" ? NOTE: newline require!

    Real-TTX

  3. #3
    Join Date
    Sep 2005
    Location
    ABQ, NM
    Posts
    3

    TS Query in C++

    Problem solved. I tried to duplicate in C++ what I'd seen done in PHP, but it didn't work. I finally found an approach that works, and works very well for my purposes.

    The structure of the query in C++ is different than that in PHP.
    If anyone else needs to get a user list from a TS server, then PM me, or reply in this thread.

  4. #4
    Join Date
    Oct 2004
    Location
    Germany
    Posts
    1,710
    I would like to see the code as I am not so familiar with C++ and sockets.

    Thank You

  5. #5
    Join Date
    Sep 2005
    Location
    ABQ, NM
    Posts
    3
    Here is an example of getting the list of connected users in all channels:
    Code:
    	
    CSocket	socket;
    CString	strQuery;
    
    // The PL command lists the users.
    strQuery.Format(_T("pl %d\nquit\n"), nUserPort);
    
    if(!socket.Create(0, SOCK_STREAM))
    {
    	ShowError();
    	return;
    }
    if(!socket.Connect(strIP, nQueryPort))
    {
    	ShowError();
    	return;
    }
    
    int	nRet;
    BYTE	buff[2048] = "";
    lstrcpy((char*)buff, strQuery);
    
    nRet = socket.Send(buff, 100);
    Sleep(100);
    socket.Receive(pBuffer, nBuffSize);
    
    socket.Close();
    CString str(buff);
    I hope it helps.
    Here is the data returned by a server:
    Code:
    [TS]
    p_id c_id ps bs pr br pl ping logintime idletime cprivs pprivs pflags ip nick loginname
    13 1 70121 8290160 8218 1247052 0 49 23537 3278 0 0 32 "0.0.0.0" "Forsaken" "" 
    15 1 62146 7301155 196 3384 0 78 20910 20907 0 0 16 "0.0.0.0" "D-day Dodger " "" 
    16 1 60468 7383754 33457 5151119 1 58 19243 5 1 5 0 "0.0.0.0" "kamikaze" "kamikaze" 
    18 1 75039 9715414 18037 2768285 1 47 18399 0 0 0 0 "0.0.0.0" "Hind-d" "" 
    26 1 67819 9604422 2262 330191 4 62 10158 5067 0 0 0 "0.0.0.0" "|BANNED| Cpl_Kirby" "" 
    28 1 59916 8465390 2654 390899 19 34 9264 525 0 0 0 "0.0.0.0" "Wombat" "" 
    33 1 29878 3928190 4028 606382 32 48 7038 22 1 5 0 "0.0.0.0" "Who" "El Diablo" 
    36 1 21658 3036719 2072 314418 0 56 3594 1 0 0 0 "0.0.0.0" "Pooh Bear" "" 
    37 1 23053 3289551 207 23973 96 85 3285 445 0 0 0 "0.0.0.0" "Mimi The Kiwi" "" 
    38 1 14875 2109117 3185 487628 3 63 2422 46 0 0 0 "0.0.0.0" "O.B." "" 
    39 1 15218 2180095 643 93861 138 71 2172 30 0 0 0 "0.0.0.0" "RebeL" ""
    You cant really see it here, but each field is seperated by a '\t'.
    Last edited by Regolith; 20-09-2005 at 23:11.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Request Security Advice
    By Parth in forum [TeamSpeak 2] Server Support
    Replies: 0
    Last Post: 29-01-2005, 12:08
  2. Teamspeak problems, need advice
    By JA4X in forum [TeamSpeak Classic] General Questions
    Replies: 0
    Last Post: 02-04-2004, 23:30
  3. TDSoundOut.Open .. Thanks for your help and advice.
    By NAS_Demon in forum [TeamSpeak 2] Client Support
    Replies: 1
    Last Post: 14-02-2004, 00:16

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •