Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

C/S Question

Tdata

Sponsor

Is there a way to convert a Text string into a command?

I'm currently using this:
Code:
 

//create a new client socket ...

                m_socWorker = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);

                String szIPSelected  = txtIPAddress.Text;

                String szPort = txtPort.Text;

                int  alPort = System.Convert.ToInt16 (szPort,10);

            

                System.Net.IPAddress    remoteIPAddress  = System.Net.IPAddress.Parse(szIPSelected);

                System.Net.IPEndPoint   remoteEndPoint = new System.Net.IPEndPoint(remoteIPAddress, alPort);

                m_socWorker.Connect(remoteEndPoint);

                Object objData = txtData.Text;

                byte[] byData = System.Text.Encoding.ASCII.GetBytes(objData.ToString ());

                m_socWorker.Send (byData);

 

and this to recieve
Code:
 

//end receive...

                int iRx  = 0 ;

                iRx = theSockId.thisSocket.EndReceive (asyn);

                char[] chars = new char[iRx +  1];

                System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();

                int charLen = d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0);

                System.String szData = new System.String(chars);

                txtDataRx.Text = txtDataRx.Text + szData;

                WaitForData(m_socWorker );

I'd like to use this to send the server commands like Varify(uname, upass), but don't know how to convert it from a string to a function call...

Or, is there another way?
 

Tdata

Sponsor

Does it have something to do with reading the first few bytes and seeing if they equal something, then converting the rest to an object? If so, how would I do It?
 

Tdata

Sponsor

If I were to use MSSQL instead of MySQL would I still be able to access the Data from a PHP page? If I can, I can ignore the Client Server Issues for now and use the direct approach, IE call the Database from the Client Directly. Not that I know how to do that currently... MSSQL is different than MySQL...
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top