473,508 Members | 2,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP:Socket binary message to c-server

Hi!
I'm new in PHP and I have a problem on sending a socket message to
c-server. I am able to connect using socket_connect but my problem is I
have to setup TCP message in a special format as my c-server is
expacting it in as in c-Structure byte order with binary data.

For example: at server:
typedef struct
{ unsigned char msg;
unsigned char start;
unsigned char nCont;
unsigned char nError;
unsigned char nFunction;
unsigned short nRecLen;
unsigned char nData[900];
unsinged char msg1;
unsigned char end ;
} MyMsg;
where nData coulde be in format like:
struct {
int myid;
char Name[100];
char Name2[100];
int Type;
int Working;
int Alarm;
int Auto;
char num[20];
}
How should I setup my string in PHP that can fit in c-byte order like
unsinged short-2 byte, int-4-byte binary number and then character
string.

Thank you in advance.
Scall

Mar 28 '06 #1
2 4543
Hi! Chung,

Thank you for your quick reply. I think this will help me.

Thank you,
Scall

Mar 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1546
by: Sticks | last post by:
hello i want to be able to send a packet to a http server and receive the response, but i'm not quite sure how to do it. i thought of using sockets, and although i have worked out how to send...
2
4885
by: Mike Verdone | last post by:
Hello all, I'm trying to implement a PHP program that can handle streaming HTTP data through Apache. I need to somehow get access to the incoming data of the HTTP request as it arrives (i.e. I...
0
1703
by: AR | last post by:
Hi, Message queue problem. Perl program creates a message queue and send a message to it. PHP program is to receive the message. Simple. But PHP's msg_receive() is getting corrupted message. Can...
4
1738
by: DJ Craig | last post by:
This command works on my home computer: if($locsock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) echo "Socket created\n"; My home computer is running Mac OS X, and is on a small LAN behind a...
2
2235
by: Boniface Frederic | last post by:
Hello, I need to check if a user has properly open his port on his computer. He will call a script specifing the port he want to use and the script will have to check if he can open a socket on...
2
2560
by: E.T. Grey | last post by:
I am persisting nested (tree) structures in C to binary file. I want to be able to read/write this data using PHP - is this possible?. That is to say, can PHP read/write C structures to file so...
1
1830
by: rukkie | last post by:
I'm having trouble to change the color of a part of a message I'm putting together in a PHP script. The built up of the message is as follows : $message = "Update for Request number: " . $nbr ....
2
5687
by: ocpaul20 | last post by:
I am trying to play with sockets. using Windows XP - SP2 IIS PHP 5.2.3 I have searched online for this error message and I have tried the various suggestions, so now I have run out of things...
2
1940
by: ErhanBaris | last post by:
Hello, i have got every simple and important problem. i am getting web site contents. but than it is giving error. thing like this. you get maybe 3000 page and you stop server, 1 hour later you...
2
3562
by: matech | last post by:
I have a problem with uploading special characters from excel files to mysql 5. It doesn't matter if I use UTF-8 or iso-8859-1 when uploading the trademark ™ symbol. htmlspecialchars() or...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7489
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5624
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1547
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
414
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.