Jump to content

Search the Community

Showing results for tags 'php c++ sockets tcp-ip'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hey guys, I need to rewrite a example of sockets TCP/IP communication done in c++ or delphi(have this 2 examples) to PHP, but have a problem with function memcpy(c++)/move(delphi) and with the structures used in both languages. in both cases i have this 2 structures: (struct from delphi) SPMSifHdr = packed record ui32Synch1: Longword; ui32Synch2: Longword; ui16Version: Word; ui32Cmd: Longint; ui32BodySize: Longint; end; SPMSifRegisterMsg = packed record hdr1: SPMSifHdr; szLicense: Array[0..19] of char; szApplName: Array[0..19] of char; nRet: Longint; end; Code used to send message to server: procedure TForm1.btnRegisterClick(Sender: TObject); var RegMsg: SPMSifRegisterMsg; byteMsg: Array[0..(sizeof(SPMSifRegisterMsg) - 1)] of byte; begin FillChar(RegMsg, SizeOf(RegMsg), 0); SetHeader(CMD_REGISTER, RegMsg.hdr1); //Set header information StrPCopy(RegMsg.szLicense, LicEdit.Text); //build data to structure StrPCopy(RegMsg.szApplName, ApplEdit.Text); Move(RegMsg, byteMsg, sizeof(SPMSifRegisterMsg)); //copy structure to bytearray ClientSocket1.Socket.SendBuf(byteMsg, sizeof(SPMSifRegisterMsg)); //send the data end; Problems: 1º - First in PHP how i can represent one structure like are used in c++ or delphi? Note: Remember i need pass this kind of structure in socket_send method, in 'buf' param) 2º - In PHP what function do the same job like memcpy(c++)/move(delphi)? Note: For me it's not important put the information necessary to send directly to the memory block, but it's important convert the information to hex(?) like happens in c++ or delphi. Structure with information before memcpy: Result of memcpy function/information send to server: I'm desperate with this situation, for second problem i've tried used the function "pack()" but i have no ideia what format to use, because i don't now what is the format they need to receive. In php dont exist structures so do you think this can be a right solution so send the information??? $packed = pack('I', $pMsgBlock->hdr1) .pack('I', $pMsgBlock->szLicense) .pack('I', $pMsgBlock->szAppname) .pack('I', $pMsgBlock->nRet); If necessary i can give more information.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.