protected function socket()
{
//创建socket资源
$this->_socket = socket_create(AF_INET, SOCK_STREAM, getprotobyname('tcp'));
if (!$this->_socket) {
$this->_errorMessage = socket_strerror(socket_last_error());
return false;
}
socket_set_block($this->_socket);
//设置阻塞模式
//连接服务器
if (!socket_connect($this->_socket, $this->_sendServer, $this->_port)) {
$this->_errorMessage = socket_strerror(socket_last_error());
return false;
}
$str = socket_read($this->_socket, 1024);
if (!preg_match("/220+?/", $str)) {
$this->_errorMessage = $str;
return false;
}
return true;
}