jearca Posted December 23, 2014 Share Posted December 23, 2014 i have a code in c# and here use GetBytes(msg) for SSlStream.write, here send and received data correctly, here all work fine, now i want to make the same event in php, but here i cant see a SslSteam or similar(i think no problem, becouse i working with socket_connection, and i think SSL is only for security), now for compare i stop the code in c# for see what data is sending and try to convert in php, for send here, i can see a data byte{} in c# and with ` $message=unpack('C*',$message);` i can convert the string to byte[], comparing with c# value is the same so, here all is ok, my problem is when i try to write the request, becouse in SslStream.write accpet byte[] but socket_write no accept whe i try send ` socket_write($socket, '\n', strlen($message))` i have a error : socket_write() expects parameter 2 to be string and obvius is becouse socket_write() only accept string, but so.. as i can send my byte[], becouse the server only accept a byte[] please help me PD> my problem is how i can send the byte[], i dont know if can send eq socket_write($socket, $message[1], strlen($message)), or what is which is the right way, note please $message first is a string as the server only accept byte i use unpack for create a $message[] as byte/integer eq with 70 items, etc, here is ok, becouse comparing with my program in c# give the same value(same array), but now i need send this $message[], but i cant becouse $message now is a byte or integer[], and socket_write only aceppt string, please help me Quote Link to comment Share on other sites More sharing options...
kicken Posted December 23, 2014 Share Posted December 23, 2014 The equivalent of a c#'s byte[] type in PHP would just be a string. So just send your string, there is no need for the unpack call. socket_write($socket, $message); I would recommend you use the streams api rather than the socket extension. It is a newer and better supported api. It will also allow you to easily do SSL as well if you need it, which you probably do if your C# code is using SSL. Quote Link to comment Share on other sites More sharing options...
jearca Posted December 23, 2014 Author Share Posted December 23, 2014 the problem is not getting response from server when sending the text string in the application c # I get, and I think that c # send a byte [], is why I use unpack that this gives me a byte [] as in c #, the problem is not how to send Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.