@@ -58,6 +58,11 @@ public function Open( string $Address, int $Port, int $Timeout, int $Engine ) :
5858
5959 public function Write ( int $ Header , string $ String = '' ) : bool
6060 {
61+ if ( $ this ->Socket === null )
62+ {
63+ throw new SocketException ( 'Not connected. ' , SocketException::NOT_CONNECTED );
64+ }
65+
6166 $ Command = pack ( 'ccccca* ' , 0xFF , 0xFF , 0xFF , 0xFF , $ Header , $ String );
6267 $ Length = strlen ( $ Command );
6368
@@ -75,6 +80,11 @@ public function Write( int $Header, string $String = '' ) : bool
7580 */
7681 public function Read ( ) : Buffer
7782 {
83+ if ( $ this ->Socket === null )
84+ {
85+ throw new SocketException ( 'Not connected. ' , SocketException::NOT_CONNECTED );
86+ }
87+
7888 $ Data = fread ( $ this ->Socket , self ::MaxPacketLength );
7989 $ Buffer = new Buffer ( );
8090 $ Buffer ->Set ( $ Data === false ? '' : $ Data );
@@ -86,6 +96,11 @@ public function Read( ) : Buffer
8696
8797 public function Sherlock ( Buffer $ Buffer ) : bool
8898 {
99+ if ( $ this ->Socket === null )
100+ {
101+ throw new SocketException ( 'Not connected. ' , SocketException::NOT_CONNECTED );
102+ }
103+
89104 $ Data = fread ( $ this ->Socket , self ::MaxPacketLength );
90105
91106 if ( $ Data === false || strlen ( $ Data ) < 4 )
0 commit comments