473,666 Members | 2,382 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 4555
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
1566
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 data to the http server, i have no idea how to receive the responses. any help wuld be greatly appreciated. this is what i've got so far. i know that the server is receiving the
2
4889
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 don't want to access the FILE array). Is this possible with mod_php? I think that, in general, it should be possible as I think mod_python can do it.
0
1715
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 anyone tell me what is wrong in the code? Perl code ---------
4
1743
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 NAT router with a hardware firewall (no software firewall). I tried to execute the same command on a school computer. It's running XP Pro and is on a large LAN behind a NAT router and a (very overprotective) hardware firewall. It's also running...
2
2243
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 the IP:Port. Here is a what I have tried but it doesn't work, even if the port is properly open : -----------------------------Script ------------------ <?php
2
2581
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 that the contents may be transferred to a C client app? The idea is that I store the binary files at the server end and clients can request for the file(s). Is this possible ? PS- the client is (of course) a C++ client, capable of understanding...
1
1840
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 . "\n" . "Project name: " . $prjname . "\n" . $yournamestring . $yrname . "\n" . "Your email address:" . $yremail . "\n" . "Address on site:". $osaddr . "\n" . .... ;
2
5693
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 to try. So far I have: 1) uncommented extension=php_sockets.dll in php.ini
2
1946
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 try again doing same things but this time you get only 1 page or 2 page. is it hp cache problem or remote server is banning ip?
2
3576
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 htmletities() doesn't help? the database doesn't show the data in the field but replaces it with the binary/Image information. the following are examples of how I've tried loading the data along with UTF-8 or iso-8859-1:
0
8440
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8352
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8780
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8636
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7378
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6189
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5661
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2765
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 we have to send another system
2
2005
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.