kushal4 Posted August 11, 2017 Share Posted August 11, 2017 (edited) Hi,Is there any api function in php which whould tell how the length of packet recieved by the socket?For example there is an api function in C linux which ioctl() which returns the length of the packet recieved by the socket.Thanks Edited August 11, 2017 by kushal4 don't do that highlighting thing Quote Link to comment Share on other sites More sharing options...
requinix Posted August 11, 2017 Share Posted August 11, 2017 ioctl is very, very low level. Much lower than PHP is meant to go. If you're talking about a packet you received from a socket you have in your own code then just do an strlen() on the received string. Quote Link to comment Share on other sites More sharing options...
kushal4 Posted August 11, 2017 Author Share Posted August 11, 2017 What i mean is i dont want to hardcode the value in socket_read() or any socket api function.First i want to know the length of the data which the socket has recieved and accordingly i want to perform socket_read() based on that length. Quote Link to comment Share on other sites More sharing options...
requinix Posted August 11, 2017 Share Posted August 11, 2017 Make it non-blocking and pick a number. Or use socket_recv(). 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.