Home > Backend Development > PHP Tutorial > socket和pack的问题。

socket和pack的问题。

WBOY
Release: 2016-06-23 14:04:18
Original
986 people have browsed it

$message = '';$message .= pack("a99", $mail);$message .= pack("a32", $pass);$message .= pack("a19", $action);$from = '';$port = 0;//echo $message;if ($socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP)){	//socket_bind($socket, '127.0.0.1', 27015);	socket_sendto($socket, $message, strlen($message), 0, $server_ip, $server_port);	$ret = socket_recvfrom($socket, $result, 12, MSG_WAITALL, $from, $port);}
Copy after login


使用这段代码发送UDP结构体不成功,把pack注释掉再执行,就没问题。
socket_sendto没发送成功,对方接收不到消息,没有返回数据。就一直阻塞着- -
UDP怎么发送结构体?


回复讨论(解决方案)

没人回答???

既无完整的代码,又无接收端
谁知到你要干什么?

不要怪人家不睬你,想猜也没有条件

呵呵呵呵呵呵呵。
本来就是一个简单的测试程序,还需要贴完整代码?
说得很清楚了。没人回答就算了。

这么说是要我做一个接收端来监听罗
我要说没问题,你信么?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template