EC-CUBE
Public メソッド | 変数
クラス Net_Socket
Net_Socketに対する継承グラフ
Inheritance graph
[凡例]
Net_Socketのコラボレーション図
Collaboration graph
[凡例]

Public メソッド

 connect ($addr, $port=0, $persistent=null, $timeout=null, $options=null)
 disconnect ()
 setNewline ($newline)
 isBlocking ()
 setBlocking ($mode)
 setTimeout ($seconds, $microseconds)
 setWriteBuffer ($size)
 getStatus ()
 gets ($size=null)
 read ($size)
 write ($data, $blocksize=null)
 writeLine ($data)
 eof ()
 readByte ()
 readWord ()
 readInt ()
 readString ()
 readIPAddress ()
 readLine ()
 readAll ()
 select ($state, $tv_sec, $tv_usec=0)
 enableCrypto ($enabled, $type)

変数

 $fp = null
 $blocking = true
 $persistent = false
 $addr = ''
 $port = 0
 $timeout = false
 $lineLength = 2048
 $newline = "\r\n"

関数

connect ( addr,
port = 0,
persistent = null,
timeout = null,
options = null 
)

Connect to the specified port. If called when the socket is already connected, it disconnects and connects again.

引数:
string$addrIP address or host name.
integer$portTCP port number.
boolean$persistent(optional) Whether the connection is persistent (kept open between requests by the web server).
integer$timeout(optional) How long to wait for data.
array$optionsSee options for stream_context_create.

public

戻り値:
boolean | PEAR_Error True on success or a PEAR_Error on failure.

Disconnects from the peer, closes the socket.

public

戻り値:
mixed true on success or a PEAR_Error instance otherwise
enableCrypto ( enabled,
type 
)

Turns encryption on/off on a connected socket.

引数:
bool$enabledSet this parameter to true to enable encryption and false to disable encryption.
integer$typeType of encryption. See stream_socket_enable_crypto() for values.
参照:
http://se.php.net/manual/en/function.stream-socket-enable-crypto.php public
戻り値:
false on error, true on success and 0 if there isn't enough data and the user should try again (non-blocking sockets only). A PEAR_Error object is returned if the socket is not connected
eof ( )

Tests for end-of-file on a socket descriptor.

Also returns true if the socket is disconnected.

public

戻り値:
bool
gets ( size = null)

Get a specified line of data

引数:
int$size??

public

戻り値:
$size bytes of data from the socket, or a PEAR_Error if not connected.
getStatus ( )

Returns information about an existing socket resource. Currently returns four entries in the result array:

timed_out (bool) - The socket timed out waiting for data
blocked (bool) - The socket was blocked
eof (bool) - Indicates EOF event
unread_bytes (int) - Number of bytes left in the socket buffer

public

戻り値:
mixed Array containing information about existing socket resource or a PEAR_Error instance otherwise

Find out if the socket is in blocking mode.

public

戻り値:
boolean The current blocking mode.
read ( size)

Read a specified amount of data. This is guaranteed to return, and has the added benefit of getting everything in one fread() chunk; if you know the size of the data you're getting beforehand, this is definitely the way to go.

引数:
integer$sizeThe number of bytes to read from the socket.

public

戻り値:
$size bytes of data from the socket, or a PEAR_Error if not connected.
readAll ( )

Read until the socket closes, or until there is no more data in the inner PHP buffer. If the inner buffer is empty, in blocking mode we wait for at least 1 byte of data. Therefore, in blocking mode, if there is no data at all to be read, this function will never exit (unless the socket is closed on the remote end).

public

戻り値:
string All data until the socket closes, or a PEAR_Error if not connected.
readByte ( )

Reads a byte of data

public

戻り値:
1 byte of data from the socket, or a PEAR_Error if not connected.
readInt ( )

Reads an int of data

public

戻り値:
integer 1 int of data from the socket, or a PEAR_Error if not connected.

Reads an IP Address and returns it in a dot formatted string

public

戻り値:
Dot formatted string, or a PEAR_Error if not connected.
readLine ( )

Read until either the end of the socket or a newline, whichever comes first. Strips the trailing newline from the returned data.

public

戻り値:
All available data up to a newline, without that newline, or until the end of the socket, or a PEAR_Error if not connected.

Reads a zero-terminated string of data

public

戻り値:
string, or a PEAR_Error if not connected.
readWord ( )

Reads a word of data

public

戻り値:
1 word of data from the socket, or a PEAR_Error if not connected.
select ( state,
tv_sec,
tv_usec = 0 
)

Runs the equivalent of the select() system call on the socket with a timeout specified by tv_sec and tv_usec.

引数:
integer$stateWhich of read/write/error to check for.
integer$tv_secNumber of seconds for timeout.
integer$tv_usecNumber of microseconds for timeout.

public

戻り値:
False if select fails, integer describing which of read/write/error are ready, or PEAR_Error if not connected.
setBlocking ( mode)

Sets whether the socket connection should be blocking or not. A read call to a non-blocking socket will return immediately if there is no data available, whereas it will block until there is data for blocking sockets.

引数:
boolean$modeTrue for blocking sockets, false for nonblocking.

public

戻り値:
mixed true on success or a PEAR_Error instance otherwise
setNewline ( newline)

Set the newline character/sequence to use.

引数:
string$newlineNewline character(s)
戻り値:
boolean True
setTimeout ( seconds,
microseconds 
)

Sets the timeout value on socket descriptor, expressed in the sum of seconds and microseconds

引数:
integer$secondsSeconds.
integer$microsecondsMicroseconds.

public

戻り値:
mixed true on success or a PEAR_Error instance otherwise
setWriteBuffer ( size)

Sets the file buffering size on the stream. See php's stream_set_write_buffer for more information.

引数:
integer$sizeWrite buffer size.

public

戻り値:
mixed on success or an PEAR_Error object otherwise
write ( data,
blocksize = null 
)

Write a specified amount of data.

引数:
string$dataData to write.
integer$blocksizeAmount of data to write at once. NULL means all at once.

public

戻り値:
mixed If the socket is not connected, returns an instance of PEAR_Error If the write succeeds, returns the number of bytes written If the write fails, returns false.
writeLine ( data)

Write a line of data to the socket, followed by a trailing newline.

引数:
string$dataData to write

public

戻り値:
mixed fputs result, or an error

構造体

string $addr = ''

The IP address to connect to.

boolean $blocking = true

Whether the socket is blocking. Defaults to true.

resource $fp = null

Socket file pointer.

integer $lineLength = 2048

Number of bytes to read at a time in readLine() and readAll(). Defaults to 2048.

string $newline = "\r\n"

The string to use as a newline terminator. Usually "\r\n" or "\n".

boolean $persistent = false

Whether the socket is persistent. Defaults to false.

integer $port = 0

The port number to connect to.

integer $timeout = false

Number of seconds to wait on socket connections before assuming there's no more data. Defaults to no timeout.


このクラスの説明は次のファイルから生成されました:
 全て データ構造 ネームスペース 関数 変数