Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
_settimeout example
return
FALSE;
}
return
true;
}
function
_connect
(
$host
,
$port
)
{
$this
->
SendMSG
(
"Creating socket"
)
;
if
(
!
(
$sock
= @
socket_create
(
AF_INET, SOCK_STREAM, SOL_TCP
)
)
)
{
$this
->
PushError
(
'_connect','socket create failed',
socket_strerror
(
socket_last_error
(
$sock
)
)
)
;
return
FALSE;
}
if
(
!
$this
->
_settimeout
(
$sock
)
)
return
FALSE;
$this
->
SendMSG
(
"Connecting to \"".
$host
.":".
$port
."\""
)
;
if
(
!
(
$res
= @
socket_connect
(
$sock
,
$host
,
$port
)
)
)
{
$this
->
PushError
(
'_connect','socket connect failed',
socket_strerror
(
socket_last_error
(
$sock
)
)
)
;
@
socket_close
(
$sock
)
;
return
FALSE;
}
$this
->_connected=true;
return
$sock
;
}
function
_readmsg
(
$fnction
="_readmsg"
)
{
function
SetUmask
(
$umask
=0022
)
{
$this
->_umask=
$umask
;
umask
(
$this
->_umask
)
;
$this
->
SendMSG
(
"UMASK 0".
decoct
(
$this
->_umask
)
)
;
return
TRUE;
}
function
SetTimeout
(
$timeout
=30
)
{
$this
->_timeout=
$timeout
;
$this
->
SendMSG
(
"Timeout ".
$this
->_timeout
)
;
if
(
$this
->_connected
)
if
(
!
$this
->
_settimeout
(
$this
->_ftp_control_sock
)
)
return
FALSE;
return
TRUE;
}
function
connect
(
$server
=NULL
)
{
if
(
!
empty
(
$server
)
)
{
if
(
!
$this
->
SetServer
(
$server
)
)
return
false;
}
if
(
$this
->_ready
)
return
true;
$this
->
SendMsg
(
'Local OS : '.
$this
->OS_FullName
[
$this
->OS_local
]
)
;
if
(
!
(
$this
->_ftp_control_sock =
$this
->
_connect
(
$this
->_host,
$this
->_port
)
)
)
{
$this
->
SendMSG
(
"Error : Cannot connect to remote host \"".
$this
->_fullhost." :".
$this
->_port."\""
)
;