Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7953049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:02:53+00:00 2026-06-04T03:02:53+00:00

This is C code. #pragma pack(push,1) typedef struct _DATA_PKT_D1 { char length[2]; char command[2];

  • 0

This is C code.

#pragma pack(push,1)
typedef struct _DATA_PKT_D1
{
    char    length[2];
    char    command[2];
    char    src[64];
    char    lordId;
    char    user_id[20];
    int     level;
    char    isFine;
    char    company_code;
}DATA_PKT_D1;
#pragma pack(pop)

DATA_PKT_D1 *pkt = malloc(sizeof(DATA_PKT_D1);

//send pkt through TCP socket. 

Data packet is 95byte.
I know php has also tcp socket function.
But, is it possible to make the packet exactly same in php? (95 byte I mean)
and send the data through tcp?

I doubt that php has binary level struct functionality…

Any hints plz~

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:02:54+00:00Added an answer on June 4, 2026 at 3:02 am

    Yeah, it’s totall possible to construct binary data with PHP, although a bit, no, a lot, less elegant than with C. You need the pack/unpack functions, that let you write binary buffers from php variables. see http://php.net/manual/en/function.pack.php

    I’ve implemented UDP servers and clients for binary protocols (even encrypted) in the past, it’s ugly but it works. the only thing you should be careful with is endianness.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#include <stdio.h> #pragma pack(push) #pragma (1) typedef struct contact { char firstname [40]; char
I just saw this code #pragma warning disable 659, 660, 661 MSDN article is
I'm capturing images using this code #pragma mark - image capture // Create and
I am having some trouble getting this simple code to work: #pragma once #include
now what is wrong with this code! Header: #pragma once #include <string> using namespace
#pragma alloc_text(PAGE, foo) void foo() { } This code is usually used in device
Look at this code: this is struct definition file with 1byte struct packing (for
This code gives me warnings: $ cat test.c #include<stdio.h> #include<time.h> int main() { time_t
I'd like serialize QVector into char* array. I do this by the following code:
This Code: Something = new Guid() is returning: 00000000-0000-0000-0000-000000000000 all the time and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.