Click here to Skip to main content
15,913,854 members
Home / Discussions / C#
   

C#

 
QuestionRemoting & Events ("Exception has been thrown by the target of an invocation.”) Pin
bluescreen7611-Mar-10 8:41
bluescreen7611-Mar-10 8:41 
AnswerRemoting & Events ("Exception has been thrown by the target of an invocation.”) - urgent! Pin
bluescreen7616-Mar-10 4:18
bluescreen7616-Mar-10 4:18 
QuestionOutlook addin integration problem with Outlook 2007 Pin
mosh_3311-Mar-10 6:52
mosh_3311-Mar-10 6:52 
QuestionSwitch versus an array of delegates Pin
PIEBALDconsult11-Mar-10 5:36
mvePIEBALDconsult11-Mar-10 5:36 
AnswerRe: Switch versus an array of delegates Pin
Saksida Bojan11-Mar-10 5:43
Saksida Bojan11-Mar-10 5:43 
AnswerRe: Switch versus an array of delegates Pin
Keith Barrow11-Mar-10 5:54
professionalKeith Barrow11-Mar-10 5:54 
GeneralRe: Switch versus an array of delegates Pin
PIEBALDconsult11-Mar-10 6:45
mvePIEBALDconsult11-Mar-10 6:45 
AnswerRe: Switch versus an array of delegates Pin
harold aptroot11-Mar-10 6:00
harold aptroot11-Mar-10 6:00 
GeneralRe: Switch versus an array of delegates Pin
PIEBALDconsult11-Mar-10 6:53
mvePIEBALDconsult11-Mar-10 6:53 
GeneralRe: Switch versus an array of delegates Pin
harold aptroot11-Mar-10 8:23
harold aptroot11-Mar-10 8:23 
GeneralRe: Switch versus an array of delegates Pin
PIEBALDconsult11-Mar-10 10:12
mvePIEBALDconsult11-Mar-10 10:12 
GeneralRe: Switch versus an array of delegates Pin
harold aptroot11-Mar-10 10:44
harold aptroot11-Mar-10 10:44 
AnswerRe: Switch versus an array of delegates Pin
Luc Pattyn11-Mar-10 6:04
sitebuilderLuc Pattyn11-Mar-10 6:04 
GeneralRe: Switch versus an array of delegates Pin
Dave Kreskowiak11-Mar-10 6:38
mveDave Kreskowiak11-Mar-10 6:38 
GeneralRe: Switch versus an array of delegates Pin
Luc Pattyn11-Mar-10 6:58
sitebuilderLuc Pattyn11-Mar-10 6:58 
GeneralRe: Switch versus an array of delegates Pin
DaveyM6911-Mar-10 7:56
professionalDaveyM6911-Mar-10 7:56 
GeneralRe: Switch versus an array of delegates Pin
PIEBALDconsult11-Mar-10 8:03
mvePIEBALDconsult11-Mar-10 8:03 
GeneralRe: Switch versus an array of delegates Pin
Dave Kreskowiak11-Mar-10 9:11
mveDave Kreskowiak11-Mar-10 9:11 
GeneralRe: Switch versus an array of delegates Pin
dybs11-Mar-10 17:28
dybs11-Mar-10 17:28 
GeneralRe: Switch versus an array of delegates Pin
Luc Pattyn11-Mar-10 17:38
sitebuilderLuc Pattyn11-Mar-10 17:38 
GeneralRe: Switch versus an array of delegates Pin
PIEBALDconsult11-Mar-10 6:41
mvePIEBALDconsult11-Mar-10 6:41 
QuestionCreating system of separation access rights Pin
Xgener11-Mar-10 5:26
Xgener11-Mar-10 5:26 
AnswerRe: Creating system of separation access rights Pin
Saksida Bojan11-Mar-10 5:56
Saksida Bojan11-Mar-10 5:56 
QuestionOutlook - with Hotmail account Pin
chiky_ancutza11-Mar-10 5:21
chiky_ancutza11-Mar-10 5:21 
QuestionGameServer Query A2S_PLAYER Problem Pin
Nokia555611-Mar-10 5:21
Nokia555611-Mar-10 5:21 
Hello,

I can't get the challenge and player respond working, it currently responds no player time, score only name, But the names are to little strange.
public string Challenge(string servIP, int servPORT)
            {
                byte[] buffer = new byte[100 * 1024];
                byte[] PlayerQuery = { 0xff, 0xff, 0xff, 0xff, 0x55, 0x65 };

                Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

                IPEndPoint ipEP = new IPEndPoint(IPAddress.Parse(servIP), servPORT);

                EndPoint EP = (EndPoint)ipEP;

                socket.ReceiveTimeout = 1000;

                socket.SendTo(PlayerQuery, PlayerQuery.Length, SocketFlags.None, EP);

                int recvBytes = socket.ReceiveFrom(buffer, ref EP);
                return ParseChallenge(buffer);
            }

            private string ParseChallenge(byte[] resp)
            {
                _CHALLANGE = System.Text.Encoding.ASCII.GetString(resp, 5, 4);
                return _CHALLANGE;
            }

            private SourceQuery ParsePlayers(byte[] resp)
            {
                SourceQuery ret = new SourceQuery();
                int i = 0;
                ret.PPlayers = Encoding.ASCII.GetString(resp);
                /*while (pNr < numPlayers - 2 && offset < resp.Length)
                {
                    offset += 1;
                    string plname = GetString(resp, offset, resp.Length);
                    offset += ret._players[pNr].Name.Length;
                    int plscore = BitConverter.ToInt32(resp, offset);
                    offset += 4;
                    pNr = ret._players.Add(new Player(plname, plscore));
                }*/
                return ret;
            }

            public SourceQuery Players(string servIP, int servPORT)
            {
                byte[] buffer = new byte[4096];
                string challenge = Challenge(servIP, servPORT);
                byte[] PlayerQuery = { 0xff, 0xff, 0xff, 0xff, 0x55 };
                string pQuery = Encoding.ASCII.GetString(PlayerQuery);
                byte[] Query = Encoding.ASCII.GetBytes(pQuery + challenge);

                Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

                IPEndPoint ipEP = new IPEndPoint(IPAddress.Parse(servIP), servPORT);

                EndPoint EP = (EndPoint)ipEP;

                socket.ReceiveTimeout = 1500;

                socket.SendTo(PlayerQuery, PlayerQuery.Length, SocketFlags.None, EP);

                int recvBytes = socket.ReceiveFrom(buffer, ref EP);
                return ParsePlayers(buffer);
            }

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.