miseleigh Posted March 20, 2008 Share Posted March 20, 2008 I'm using UDP sockets to talk to an Ether IO 24 board, and I need to make my commands get through properly, so I'm trying to read back the data I send to it. However, I'm not getting anything, and instead my browser just hangs. I don't know much about sockets (this is my first time using them) so maybe there's something I should be doing that I'm not or vice versa. Any help would be greatly appreciated. set_time_limit(0); $socket = socket_create(AF_INET, SOCK_DGRAM, 0); $result = socket_connect($sock, $IP, $Port); $cmd = pack("ci", $writeA, $xff); // writes to device - this works socket_write($sock, $cmd); $cmd = pack("c", $readA); // tells device to send data back socket_write($sock, $cmd); $buf=socket_read($sock, 2); // I get nothing here echo $buf; Link to comment https://forums.phpfreaks.com/topic/97132-socket_read-not-getting-anything/ Share on other sites More sharing options...
miseleigh Posted March 20, 2008 Author Share Posted March 20, 2008 Whoops, I had a typo in there, but it really does all work up to the read() call: $sock = socket_create(AF_INET, SOCK_DGRAM, 0); One possibility I've thought of is that the Ether doesn't know where to send its data back to. Is there a way to listen to a specific ip address & port number, since I have no way of telling the Ether who's talking to it? Link to comment https://forums.phpfreaks.com/topic/97132-socket_read-not-getting-anything/#findComment-497034 Share on other sites More sharing options...
miseleigh Posted March 20, 2008 Author Share Posted March 20, 2008 Well, nevermind, I had another typo in the command that tells the Ether to send data back, so I never sent it the right command... *doh!* Link to comment https://forums.phpfreaks.com/topic/97132-socket_read-not-getting-anything/#findComment-497102 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.